Shaktiman
Shaktiman
:01
AIM : Create an application that obtains four int values from the user and displays
the products.
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PRODUCT
{
class Program
{
static void Main(string[] args)
{
int n1, n2, n3, n4, product;
product = n1*n2*n3*n4;
}
}
}
PRACTICAL NO.:02
AIM : Create an application to demonstrate string operations.
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PRODUCT
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Using substring function.......");
string name ="expert";
string sub = name.Substring(1, 3);
Console.WriteLine(sub);
Console.WriteLine("=====================\n");
name = "expert";
sub = name.Substring(2);
Console.WriteLine(sub);
Console.WriteLine("=================\n");
Console.WriteLine("using insert function.....");
name = "expert";
sub = name.Insert(2, "--");
Console.WriteLine(sub);
Console.WriteLine("=================\n");
Console.WriteLine("using removefunction......");
name = "ex--pert";
sub = name.Remove(2, 2);
Console.WriteLine(sub);
Console.WriteLine("==================\n");
Console.WriteLine("using trim function.......");
name = " i am c sharp expert ";
sub = name.Trim();
Console.WriteLine(sub);
Console.WriteLine("==================\n");
Console.WriteLine("using to upper function.........");
name = "expert";
sub = name.ToUpper();
Console.WriteLine(sub);
Console.ReadLine();
}
}
}
PRACTICAL NO.:03
AIM : Create an application that receives the (Student Id, Student Name, Course
Name,Date of Birth) information from a set of students. The application should
also display the information of all the students once the data entered.
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace product
{
class Program
{
int stdid;
string name;
string course_name;
string DOB;
public void getdata()
{
Console.WriteLine("Enter the student ID:");
stdid = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the student name:");
name = Console.ReadLine();
Console.WriteLine("Enter the course name:");
course_name = Console.ReadLine();
Console.WriteLine("Enter the DOB:");
DOB = Console.ReadLine();
}
public void displayinfo()
{
Console.WriteLine("student id is:" + stdid);
Console.WriteLine("name is:" + name);
Console.WriteLine("course name is:" + course_name);
Console.WriteLine("DOB is:" + DOB);
}
static void Main(string[] args)
{
Program p1 = new Program();
Program p2 = new Program();
Program p3 = new Program();
Console.WriteLine("Enter the data for student 1:");
p1.getdata();
Console.WriteLine("Enter the data for student 2:");
p2.getdata();
Console.WriteLine("Enter the data for student 3:");
p3.getdata();
Console.WriteLine("***************");
Console.WriteLine("info of student 1:");
p1.displayinfo();
Console.WriteLine("info of student 2:");
p2.displayinfo();
Console.WriteLine("info of student 3:");
p3.displayinfo();
Console.ReadLine();
}
}
}
PRACTICAL NO.:04
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace product
{
class Program
{
PRACTICAL NO.:05
AIM : Create an application to demonstrate vowels .
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace product
class Program
char ch;
ch = Convert.ToChar(Console.ReadLine());
switch (ch)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
break;
default:
break;
Console.ReadLine();
}
PRACTICAL NO.:06
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace product
class Program
int num;
num = Convert.ToInt32(Console.ReadLine());
num /= 10;
Console.ReadLine();
}
PRACTICAL NO.:07
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace product
{
class Program
{
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PRODUCT
{
class Program
{
public int addarray(params int[] list)
{
int sum = 0;
foreach(int i in list)
{
sum = sum + i;
}
return sum;
}
static void Main(string[] args)
{
int[] no = { 1, 2, 3, 4, 5, 6 };
Program p = new Program();
Console.WriteLine("the addition of array is {0}", p.addarray(no));
Console.ReadLine();
}
}
}
PRACTICAL NO.:09
PROGRAM:
using System;
public class FunOverloading
{
public static int mul(int no1, int no2)
{
return no1 * no2;
}
public static int mul(int no1, int no2, int no3)
{
return no1 * no2 * no3;
}
public static float mul(float no1, float no2)
{
return no1 * no2;
}
}
public class Program
{
public static void Main()
{
Console.WriteLine("Multiplication of two integer numbers: " +
FunOverloading.mul(1, 22));
Console.WriteLine("Multiplication of three integer numbers: " +
FunOverloading.mul(1, 5, 10));
Console.WriteLine("Multiplication of two float numbers: " +
FunOverloading.mul(1.2F, 3.4F));
Console.ReadLine();
}
}
PRACTICAL NO.:10
PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Add
{
class Add
{
public Add(int a)
{
Console.WriteLine("user enter single no. so addition is :" + a);
}
public Add(int a,int b)
{
Console.WriteLine("the addition of two number is :" + (a + b ));
}
public Add(int a,int b,int c)
{
Console.WriteLine("the addition of three number is :" + (a + b + c));
}
static void Main(string[] args)
{
Add p1 = new Add(5,6);
Add p2 = new Add(5);
Add p3 = new Add(5,6,7);
Add p4 = new Add(3,4);
Console.ReadLine();
}
}
}
PRACTICAL NO.:11(A)
PROGRAM:
using System;
public class EmpDemo
{
public float salary = 40000;
}
public class Bonus : EmpDemo
{
public float bonus = 10000;
}
class FinalClass
{
public static void Main(string[] args)
{
Bonus b1 = new Bonus();
Console.WriteLine("Salary : " + b1.salary);
Console.WriteLine("Bonus : " + b1.bonus);
Console.ReadLine();
}
}
PRACTICAL NO.:11(B)
PROGRAM:
using System;
public class Animal
{
public void Eat()
{ Console.WriteLine("Eating..."); }
}
public class Dog : Animal
{
public void Bark()
{ Console.WriteLine("Barking..."); }
}
public class BabyDog : Dog
{
public void Weep()
{ Console.WriteLine("Weeping..."); }
}
public class MultilevelInheritance
{
public static void Main(string[] args)
{
BabyDog dog = new BabyDog();
dog.Eat();
dog.Bark();
dog.Weep();
Console.ReadLine();
}
}
PRACTICAL NO.:11(C)
PROGRAM:
using System;
namespace HierarchicalInheritaceDemo
{
class A
{
public void show()
{
Console.WriteLine("Welcome to the C#.");
}
}
class B : A
{
public void display()
{
Console.WriteLine("Hello TYIT.");
}
}
class C : A
{
public void show1()
{
Console.WriteLine("The subject name is Advanced Web Programming.");
}
}
class hierarchical
{
public static void Main()
{
B objl = new B();
C obj2 = new C();
objl.show();
objl.display();
obj2.show1();
Console.ReadLine();
}
}
}
PRACTICAL NO.:12
PROGRAM:
using System;
namespace InterfaceDemo
class Program
ch.message();
Console.ReadKey();
public interface I1
void message();
public interface I2
void message();
}
Console.ReadLine();
}
PRACTICAL NO.:13
PROGRAM:
using System;
namespace exception_handling
{
class Bank : Exception
{
public Bank(string msg) : base(msg)
{
}
}
class Program
{
public int AccountNo;
public double Balance;
public Program(int AccNo, double bal)
{
try
{
AccountNo = AccNo;
Balance = bal;
if (bal < 500) throw new Bank("Oops !!! Amount is not sufficient");
}
finally
{
Console.WriteLine("Account Number : {0} and Balance: {1}",
AccountNo, Balance);
}
}
static void Main(string[] args)
{
int a;
double b;
Console.WriteLine("Enter the Account Number and Balance : ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToDouble(Console.ReadLine());
Program obj = new Program(a, b);
Console.Read();
}
}
}
PRACTICAL NO.:14
AIM : Create simple application to demonstrate delegates .
PROGRAM:
using System;
namespace DelegateEX
class A
class Program
m(5, 10);
m1(5, 10);
Console.ReadKey();
PRACTICAL NO.:15
AIM : Write a program to create a website to display product of four number .
PROGRAM:
default.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> Multiplication of 4 Numbers </title>
<style type="text/css">
.auto-style1 {
width: 70%;
}
.auto-style2 {
width: 218px;
}
.auto-style3 {
width: 218px;
height: 30px;
}
.auto-style4 {
height: 30px;
}
</style>
</head>
<body id="Result">
<form id="form1" runat="server">
<div>
<table class="auto-style1" align="center">
<tr>
<td align="center" colspan="3" style="font-family: 'times New
Roman', Times, serif; font-size: x-large; background-color: #FFFF00; color:
#FF00FF;">Multiplication of 4 Numbers </td>
</tr>
<tr>
<td class="auto-style2">Enter First Number</td>
<td>:</td>
<td>
<asp:TextBox ID="txt1no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Second Number</td>
<td>:</td>
<td>
<asp:TextBox ID="Txt2no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Third Number</td>
<td>:</td>
<td>
<asp:TextBox ID="Txt3no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Fourth Number</td>
<td>:</td>
<td>
<asp:TextBox ID="Txt4no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style3">
<asp:Button ID="Multiplication" runat="server"
OnClick="Multiplication_Click" Text="Multiplication" />
</td>
<td class="auto-style4"></td>
<td class="auto-style4"></td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Result" runat="server"></asp:Label>
</td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
PRACTICAL NO.:16
AIM : Create Web Form to demonstrate use of Adrotator Control.
PROGRAM:
XML File.xml
<Advertisements>
<Ad>
<ImageUrl>~/Images/a.png</ImageUrl>
<NavigateUrl>http://www.1800flowers.com</NavigateUrl>
<AlternateText>
Order roses
</AlternateText>
<Impressions>20</Impressions>
<Keyword>roses</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Images/b.png</ImageUrl>
<NavigateUrl>http://www.babybouquets.com.au</NavigateUrl>
<AlternateText>scenery</AlternateText>
<Impressions>20</Impressions>
<Keyword>scenery</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Images/c.png</ImageUrl>
<NavigateUrl>http://www.flowers2moscow.com</NavigateUrl>
<AlternateText>bappa</AlternateText>
<Impressions>20</Impressions>
<Keyword>bappa</Keyword>
</Ad>
</Advertisements>
OUTPUT :
PRACTICAL NO.:17
AIM : Create a website to demonstrate themes .
PROGRAM:
SkinFile.skin
<%--
Default skin template. The following skins are provided as examples only.
Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages theme="Theme1"/>
</system.web>
</configuration>
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="welcome" runat="server" Text="Welcome" />
&
nbsp;
<asp:Button ID="Button2" runat="server" Text="Home" />
</div>
</form>
</body>
</html>
OUTPUT :
PRACTICAL NO.:18
AIM : Create a web application to demonstrate use of Master page with applying
Styles for page beautifications .
PROGRAM:
MASTERPAGE.MASTER
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 328px;
}
</style>
</head>
<body>
<table class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Image ID="Image1" runat="server" Height="211px"
ImageUrl="~/gulmohar.png" Width="225px" />
</td>
<td style="border-style: dashed; font-family: 'Lucida Sans', 'Lucida
Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-
serif; font-style: oblique; color: #FF00FF; font-size: xx-large; background-color:
#00FFFF;">GULMOHAR FASHION
<br />
HOUSE</td>
</tr>
<tr>
<td class="auto-style2">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/ABOUT US.aspx">ABOUT US</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="#">CONTACT US</asp:HyperLink>
</td>
<td><asp:ContentPlaceHolder id="ContentPlaceHolder1"
runat="server"></asp:ContentPlaceHolder></td>
</tr>
<tr>
<td colspan="2" align="center" style="font-family: 'Arial Narrow';
font-size: large; font-style: italic; color: #00FFFF">© GULMOHAR
FASHION HOUSE</td>
</tr>
</table>
</div>
</form>
</body>
</html>
DEFAULT.ASPX
OUTPUT :
PRACTICAL NO.:19
AIM : Create a registration form to demonstrate various validation controls .
PROGRAM:
DEFAULT.ASPX
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
.auto-style2 {
width: 193px;
.auto-style3 {
width: 168px;
.auto-style4 {
width: 193px;
height: 26px;
.auto-style5 {
width: 168px;
height: 26px;
.auto-style6 {
height: 26px;
</style>
</head>
<body id="btnsubmit">
<div>
<table class="auto-style1">
<tr>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="txtname" ErrorMessage="THIS IS
REQUIRED FIELD" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style3">
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style3">
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style5">
</td>
<td class="auto-style6"> <asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtemail"
ErrorMessage="THIS IS REQUIRED"
ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtemail"
ErrorMessage="NOT VALID EMAIL ID" ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></
asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style3">
</td>
<td>
<asp:RangeValidator runat="server" ControlToValidate="txtage"
ErrorMessage="AGE SHOULD BE BETWEEN 18-56" ForeColor="Red"
MaximumValue="56" MinimumValue="18"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td class="auto-style3"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
</td>
<td class="auto-style3"> </td>
<td rowspan="2">
<asp:ValidationSummary ID="ValidationSummary1"
runat="server" ForeColor="Red" />
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td class="auto-style3"> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
OUTPUT :
PRACTICAL NO.:20
AIM : Create a web form to demonstrate use of user controls .
PROGRAM:
WebUserControl.ascx
<tr>
<td></td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="txtSave" runat="server" Text="Save"
onclick="txtSave_Click" />
</td>
</tr>
</table><br />
<asp:Label ID="Label1" runat="server" Text=" "></asp:Label>
WebUserControl.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc:Student ID="studentcontrol" runat="server" />
</div>
</form>
</body>
</html>
OUTPUT :