SlideShare a Scribd company logo
1 of 52
.NET PRECTICALS
1
UTTRANCHAL INSTITUTE OF MANAGEMENT
PACTICAL REPORT ON
C#
DOT NET
MASTER of COMPUTER APPLICATION
SubmittedTo:- SubmittedBy:-
.NET PRECTICALS
2
Rahul singh Abhishek kr pathak
UIM, Dehradun MCA4th
SEM,
UIM,Dehradun
.NET PRECTICALS
3
List of Programs
Serial
Number
Name of the program Remark
1 Write a program to display a hello/welcome message
2 WAP for Demonstrating Data Type Conversion
3 WAP for Demonstrating String Handling
4 Given the radius of the circle, WAP to compute the area of
the circle, circumference of the circle and display their value.
5 Admission to a professional course is subject to the
following cond
Mks in maths>=80;Mks in Physics>=75;Mks in chem.>=60;
Total Mks all three>=250 or total in maths and physics>=
180
Given the details about the mks, WAP to process the
applications to list the eligible candidates.
6 WAP that will read the value of x and evaluate the following
function
Y= { 1 for x > 0; 0 for x = 0; -1 for x < 0 }
Using a) nested if statements b) else if statements and c)
conditional operators?
7 shown below is the Floyd’s triangle
1
23
456
78910
.
.
.
79………….91
WAP to print this triangle.
8 WAP to produce the following patterns
* $$$$ 1
** $$$ 22
*** $$ 333
**** $ 4444
9 WAP to generate and then sum the Fibonacci series
10 Demonstrate the typical use of the following jump
statements:
 break
 continue
.NET PRECTICALS
4
In a single program
11 WAP for Declaring Class and invokeing a method.
12 WAP to explain the concept of boxing and unboxing
13 WAP to demonstrate the addition of byte type of variables
14 WAP for using System.Collection Namespace
15 WAP for Implementing Jagged Arrays
16 Given the two one-dimensional arrays A and B which are
sorted in ascending order. WAP to merge them into a single
sorted array C that contains every items from arrays A and
B in ascending order
17 WAP for Using Reflection Class
18 WAP for Using GDI+ Classess
19 WAP for Displaying Constructors and Destructors
20 WAP to implement Single inheritance
21 WAP to implement MultiLevel inheritance
22 WAP to implement Polymorphism
23 WAP to implement Operator Overloading
24 WAP to deal with Exception Handling
25 WAP fo displaying Randomly Generated button and Click
Event
26 WAP to Demonstrate Multi Threading Example
27 WAP to implement delegates
28 WAP to implement multicast delegates
29 WAP for displaying Data Handling Application
30 WAP to use Window Form Application
31 Design and develop application as of your own choice
.NET PRECTICALS
5
1.Write a program to display a hello/welcome message
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.Write("Welcome MCA in UIM");
Console.ReadKey();
}
}
}
.NET PRECTICALS
6
2. WAP for Demonstrating Data Type Conversion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string str1 = "123.45";
Single sngl1 = Convert.ToSingle(str1);
int x = Convert.ToInt16(sngl1);
Console.WriteLine("Single 1 = {0}", sngl1);
Console.WriteLine("Integer 1 = {0}", x);
double y = Convert.ToDouble(str1);
Console.WriteLine("Double = {0}", y);
Int16 z = Convert.ToInt16(y);
Console.WriteLine("Int16 = {0}", z);
Console.ReadLine();
}
}
}
.NET PRECTICALS
7
3.. WAP for Demonstrating String Handling
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace String_Handling
{
class Program
{
static void Main(string[] args)
{
String s1 = "preeti shahi";
String s2 = s1.Insert(2, "i");
Console.WriteLine(s2);
String s3 = "preeti shahi";
Boolean b = s3.Equals(s1);
Console.WriteLine(b.ToString());
Console.WriteLine(s1.ToLower());
Console.WriteLine(s1.ToUpper());
String s4 = s1.Substring(5);
Console.WriteLine(s4);
Console.ReadKey();
}
}
}
.NET PRECTICALS
8
4 . Given the radius of the circle, WAP to compute the area of the circle, circumference
of the circle and display their value.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Circle
{
class Program
{
static void Main(string[] args)
{
const double pi = 3.14;
Console.WriteLine("Enter the radius of the circle");
double r = Convert.ToDouble(Console.ReadLine());
double area = pi * r * r;
Console.WriteLine("Area is:" + area.ToString());
double curc = 2 * pi * r;
Console.WriteLine("Circumference is:" + curc.ToString());
Console.ReadKey();
}
}
.NET PRECTICALS
9
5.Admission to a professional course is subject to the following cond
Mks in maths>=80;Mks in Physics>=75;Mks in chem.>=60; Total Mks all three>=250
or total in maths and physics>= 180
Given the details about the mks, WAP to process the applications to list the eligible
candidates.
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the marks of Maths,Physics and
Chemistry");
int Math = int.Parse(Console.ReadLine());
int Phys = int.Parse(Console.ReadLine());
int Chem = int.Parse(Console.ReadLine());
int total = Math + Phys + Chem;
int MP = Math + Phys;
if (total >= 250 || MP >= 180)
{
if (Math >= 80 && Phys >= 75 && Chem >= 60)
{
Console.WriteLine("Candidates is Eligible");
}
else
{
Console.WriteLine("Candidates is not Eligible");
}
}
else
{
Console.WriteLine("Candidates is not Eligible");
}
Console.ReadKey();
}
}
.NET PRECTICALS
10
.NET PRECTICALS
11
6.WAP that will read the value of x and evaluate the following function
Y= { 1 for x > 0; 0 for x = 0; -1 for x < 0 }
Using a) nested if statements b) else if statements and c) conditional operators?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Evaluate_x
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the value of X");
int x = int.Parse(Console.ReadLine());
int y = 0;
//Using Nested If Statement
if (x > 0)
{
y = 1;
}
else if (x == 0)
{
y = 0;
}
else if (x < 0)
{
y = -1;
}
Console.WriteLine("Using else-if Statement:" + y.ToString());
y = (x == 0) ? 0 : (x > 0) ? 1 : (x < 0) ? -1 : 0;
Console.WriteLine("Using Conditional Operation:" + y.ToString());
Console.ReadKey();
}
}
}
.NET PRECTICALS
12
.NET PRECTICALS
13
7. shown below is WAP to show the Floyd’s triangle on the basis of rows
using System;
class Program
{
static void Main(string[] args)
{
int n, i, c, a = 1;
Console.WriteLine("Enter the number of rows till you want to
print");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
for (c = 1; c <= i; c++)
{
Console.Write(a.ToString());
a++;
}
Console.WriteLine();
}
Console.ReadKey();
}
}
.NET PRECTICALS
14
8. shown below is the Floyd’s triangle
1
23
456
78910
.
.
.
79………….91
WAP to print this triangle.
using System;
class Program
{
static void Main(string[] args)
{
int n, i, c, a = 1;
bool k = true;
Console.WriteLine("Enter the number till you want to print");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
for (c = 1; c <= i; c++)
{
if(a==n)
{
k=false;
break;
}
Console.Write( a.ToString());
a++;
}
if (k == false)
{
break;
}
Console.WriteLine();
}
Console.ReadKey();
}
}
.NET PRECTICALS
15
.NET PRECTICALS
16
9.WAP to produce the following patterns
* $$$$ 1
** $$$ 22 .
*** $$ 333
**** $ 4444
using System;
class Program
{
static void Main(string[] args)
{
int n, c, k;
Console.WriteLine("Enter The Number Of Rows");
n = int.Parse(Console.ReadLine());
//Number Tirangle
for (c = 1; c <= n; c++)
{
for (k = 1; k <= c; k++)
{
Console.Write(c);
}
Console.WriteLine();
}
Console.WriteLine();
//Dollar Tirangle
for (c = 1; c <= n; c++)
{
for (k = 1; k <= c; k++)
{
Console.Write("$");
}
Console.WriteLine();
}
Console.WriteLine();
// Star Traingle
for (c = n; c >= 1; c--)
{
for (k = 1; k <= c; k++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
.NET PRECTICALS
17
.NET PRECTICALS
18
10..WAP to generate and then sum the fibonacci series:-
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the terms in Fibonacci series:-");
int n = int.Parse(Console.ReadLine());
int a = -1, b = 1, c = 0, sum = 0;
for (int i = 1; i <= n; i++)
{
c = a + b;
sum = sum + c;
a = b;
b = c;
}
Console.WriteLine(sum.ToString());
Console.ReadKey();
}
}
.NET PRECTICALS
19
11. Demonstrate the typical use of the following jump statements:
 break
 continue
In a single program
using System;
class Program
{
static void Main(string[] args)
{
//Continue Statement
for (int i = 0; i <= 15; i++)
{
if (i == 5)
{
continue;
}
Console.Write(i.ToString() + " ");
}
Console.WriteLine();
//Break Statement
for (int i = 0; i <= 15; i++)
{
if (i == 10)
{
break;
}
Console.Write(i.ToString() + " ");
}
Console.ReadKey();
}
}
.NET PRECTICALS
20
.NET PRECTICALS
21
12.WAP for Declaring Class and invoking a method.
using System;
class Rect
{
int l, b;
public Rect(int l, int b)
{
this.l = l;
this.b = b;
}
public int getArea()
{
return l * b;
}
}
class Program
{
static void Main(string[] args)
{
Rect a = new Rect(28, 15);
Console.WriteLine("Area of rectangle is : " +
a.getArea().ToString());
Console.ReadKey();
}
}
.NET PRECTICALS
22
13.WAP to explain the concept of boxing and un boxing
using System;
class Program
{
static void Main(string[] args)
{
int i = 123;
object o = i;//Boxing
Console.WriteLine("Boxing OK");
int j = (int)o; //UnBoxing
System.Console.WriteLine("Unboxing OK");
try
{
int k = (short)o;//InvalidCastException Generated
System.Console.WriteLine("Unboxing OK");
}
catch (System.InvalidCastException e)
{
System.Console.WriteLine("Incorrect Unboxing.", e.Message);
}
Console.ReadKey();
}
}
.NET PRECTICALS
23
14.WAP to demonstrate the addition of byte type of variables:-
using System;
class Program
{
static void Main(string[] args)
{
byte b1 = 88;
byte b2 = 79;
//byte sum = b1 + b2; error cannot implicitly convert int to byte
int sum = b1 + b2; //No error
Console.WriteLine(sum.ToString());
Console.ReadKey();
}
}
.NET PRECTICALS
24
15. WAP for using System.Collection Namespace
using System;
using System.Collections;
namespace system.collection_array_list
{
class Program
{
static void Main(string[] args)
{
ArrayList n = new ArrayList();
n.Add("Preeti Shahi");
n.Add("Yamini Bisht");
n.Add("Gaurav Sharma");
n.Add("Sachin Sisodia");
n.Add("Abhishek Sharma");
n.Add("Abhishek Pathak");
Console.WriteLine("Capacity=" + n.Capacity);
Console.WriteLine("Element present=" + n.Count);
for (int i = 0; i < n.Count; i++)
{
Console.Write(n[i] + " ");
}
Console.WriteLine();
//Sorting Array List
n.Sort();
for (int i = 0; i < n.Count; i++)
{
Console.Write(n[i] + " ");
}
Console.WriteLine();
//Removing An element
n.RemoveAt(2);
for (int i = 0; i < n.Count; i++)
{
Console.Write(n[i] + " ");
}
Console.ReadKey();
}
}
}
.NET PRECTICALS
25
.NET PRECTICALS
26
16.WAP for Implementing Jagged Arrays
using System;
class Program
{
static void Main(string[] args)
{
const int rows = 3;
int[][] jagArr = new int[rows][];
jagArr[0] = new int[2];
jagArr[1] = new int[3];
jagArr[2] = new int[4];
jagArr[0][1] = 67;
jagArr[1][0] = 83;
jagArr[1][1] = 57;
jagArr[2][0] = 63;
jagArr[2][3] = 14;
for (int i = 0; i < 2; i++)
{
Console.Write(jagArr[0][i] + " ");
for (int j = 0; j < 3; j++)
{
Console.Write(jagArr[1][j] + " ");
for (int k = 0; k < 4; k++)
{
Console.Write(jagArr[2][k] + " ");
} Console.WriteLine();
}
Console.WriteLine();
}
Console.ReadKey();
}
}
.NET PRECTICALS
27
.NET PRECTICALS
28
17. Given the two one-dimensional arrays A and B which are sorted in ascending order.
WAP to merge them into a single sorted array C that contains every items from arrays A
and B in ascending order
using System;
class Program
{
static void Main(string[] args)
{
int[] a = { 10, 20, 30, 40, 50, 60, 70, 80, 90 };
int[] b = { 18, 36, 54, 72, 90, 108, 126, 144, 120 };
int[] c = new int[a.Length + b.Length];
//Mearging To New Array C
a.CopyTo(c, 0);
b.CopyTo(c, a.Length);
//Sorting Array C
for (int i = 0; i < c.Length; i++)
{
for (int j = i + 1; j < c.Length; j++)
{
if (c[i] > c[j])
{
int temp = c[i];
c[i] = c[j];
c[j] = temp;
}
}
}
for (int i = 0; i < c.Length; i++)
{
Console.WriteLine(c[i]);
}
Console.ReadKey();
}
}
.NET PRECTICALS
29
.NET PRECTICALS
30
18. WAP for Using Reflection Class
using System;
using System.Reflection;
namespace Wap_To_Reflection
{
class Program
{
static void Main(string[] args)
{
Type t = typeof(System.String);
ConstructorInfo[] ci = t.GetConstructors();
Console.WriteLine("Constructors are");
foreach (ConstructorInfo ctemp in ci)
{
Console.WriteLine(ctemp.ToString());
}
Console.WriteLine();
Console.WriteLine("Methods are");
MethodInfo[] mifo = t.GetMethods();
foreach (MethodInfo mifot in mifo)
{
Console.WriteLine(mifot.ToString());
}
Console.ReadKey();
}
}
}
.NET PRECTICALS
31
19. WAP for Using GDI+ Classes
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Graphics g = CreateGraphics();
Color forecolor = Color.Black;
Color backcolor = Color.White;
Font font = new Font("Algerian", 26);
g.FillRectangle(new SolidBrush(backcolor), ClientRectangle);
g.DrawString("Hello friends … m VICKY", font, new
SolidBrush(forecolor), 15, 15);
Pen myPen = new Pen(new SolidBrush(forecolor), 2);
Point p1 = new Point(40);
Point p2 = new Point(90);
g.DrawRectangle(myPen, 50, 150, 100, 50);
g.DrawEllipse(myPen, 100, 50, 80, 40);
g.FillEllipse(Brushes.Black, 100, 50, 80, 40);
}
}
}
.NET PRECTICALS
32
.NET PRECTICALS
33
20. WAP for Displaying Constructors and Destructors
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Constructor_and_Distructor
{
class Rect
{
private int l, b;
public Rect(int l, int b)
{
Console.WriteLine("Constructor Call");
this.l = l;
this.b = b;
}
public int area()
{
return l * b;
}
Rect()
{
Console.WriteLine("Destructor call");
}
}
class Program
{
static void Main(string[] args)
{
Rect r = new Rect(32, 24);
Console.WriteLine(r.area().ToString());
Console.ReadKey();
}
}
}
.NET PRECTICALS
34
.NET PRECTICALS
35
21. WAP to implement Single inheritance
using System;
class Item
{
public void x()
{
Console.WriteLine("Item Code=***");
}
}
class Fruit : Item
{
public void type()
{
Console.WriteLine("Fruit type = Mango");
}
}
class SingleInheritance
{
static void Main(string[] args)
{
Item item = new Item();
Fruit fruit = new Fruit();
item.x();
fruit.type();
Console.ReadKey();
}
}
.NET PRECTICALS
36
22. WAP to implement MultiLevel inheritance
using System;
class Student
{
public string name;
public int age;
public Student(string name, int age)
{
this.name = name;
this.age = age;
}
}
class Player : Student
{
public string sport;
public string team;
public Player(string sport, string team, string name, int age)
: base(name, age)
{
this.sport = sport;
this.team = team;
}
}
class CricketPlayer : Player
{
public int runs;
public CricketPlayer(int runs, string sport, string team, string
name, int age)
: base(sport, team, name, age)
{
this.runs = runs;
}
public void Show()
{
Console.WriteLine("Player:" + name);
Console.WriteLine("Age:" + age);
Console.WriteLine("Sport:" + sport);
Console.WriteLine("Team:" + team);
Console.WriteLine("Runs:" + runs);
}
}
class Program
{
static void Main(string[] args)
{
CricketPlayer u = new CricketPlayer(210, "Cricket", "India",
"Sachin Tendulkar", 43);
u.Show();
Console.ReadKey();
}
}
.NET PRECTICALS
37
.NET PRECTICALS
38
23. WAP to implement Polymorphism
using System;
class Fruit
{
public virtual void display()
{
Console.WriteLine("Seasonal Fruits");
}
}
class SeasonalFruit : Fruit
{
public override void display()
{
Console.WriteLine("Seasonal Fruit:Mango");
}
}
class NonSeasonalFruit : Fruit
{
public override void display()
{
Console.WriteLine("NonSeasonal Fruit:Grapes");
}
}
class InclusionPolymorphism
{
static void Main(string[] args)
{
Fruit m = new Fruit();
m = new SeasonalFruit();//Upcasting
m.display();
m = new NonSeasonalFruit();//Upcasting
m.display();
Console.ReadKey();
}
}
.NET PRECTICALS
39
.NET PRECTICALS
40
24. WAP to implement Operator Overloading
using System;
class A
{
int a, b;
public void input(int x, int y)
{
a = x;
b = y;
}
public void output()
{
Console.WriteLine(a + " " + b);
}
public static A operator +(A a1, A a2)//Binary Operator OverLoad(+)
{
A a3 = new A();
a3.a = a1.a + a2.a;
a3.b = a1.b + a2.b;
return a3;
}
}
class B
{
static void Main()
{
A a1 = new A();
A a2 = new A();
A a3 = new A();
a1.input(38, 46);
a1.output();
a2.input(40, 59);
a2.output();
a3 = a1 + a2;
a3.output();
Console.Read();
}
}
.NET PRECTICALS
41
.NET PRECTICALS
42
25. WAP to deal with Exception Handling
using System;
class A
{
static void Main()
{
try
{
int a, b, c;
Console.WriteLine("Enter a and b:");
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = a / b;
Console.WriteLine("Output is" + c);
}
catch (Exception e)
{
Console.WriteLine("Divide by zero is an error");
}
Console.Read();
}
}
.NET PRECTICALS
43
26. WAP for displaying Randomly Generated button and Click Event
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Randomly_Generated_Button
{
public partial class RandomGenBt : Form
{
private Button b1;
private int counter1,counter2;
public RandomGenBt()
{
counter1 = 25;
counter2 = 25;
InitializeComponent();
}
private void cmdGen_Click(object sender, EventArgs e)
{
b1 = new Button();
b1.Location = new Point(counter1, counter2);
b1.Size = new Size(50, 25);
b1.Text = counter1.ToString() + " " + counter2.ToString();
b1.Click+=new EventHandler(x);
this.Controls.Add(b1);
counter1 = counter1 + 52;
counter2 = counter2 + 27;
}
private void x(object sender,EventArgs e)
{
MessageBox.Show(b1.Text.ToString());
}
}
}
.NET PRECTICALS
44
.NET PRECTICALS
45
27. WAP to Demonstrate Multi Threading Example
using System;
using System.Collections.Generic;
using System.Threading;
class Program
{
static void Main(string[] args)
{
// creating more than one thread in the application
Thread FirstThread = new Thread(FirstFunction);
Thread SecondThread = new Thread(SecondFunction);
Thread ThirdThread = new Thread(ThirdFunction);
Console.WriteLine("nThreading Starts...n");
//Starting more than one thread in the application
FirstThread.Start();
SecondThread.Start();
ThirdThread.Start();
}
public static void FirstFunction()
{
for (int number = 1; number <= 5; number++)
{
Console.WriteLine("First Thread Displays: " + number);
Thread.Sleep(200);
}
}
public static void SecondFunction()
{
for (int number = 1; number <= 5; number++)
{
Console.WriteLine("Second Thread Displays: " + number);
Thread.Sleep(500);
}
}
public static void ThirdFunction()
{
for (int number = 1; number <= 5; number++)
{
Console.WriteLine("Third Thread Displays: " + number);
Thread.Sleep(700);
}
Console.Write("nPress ENTER to quit...");
Console.ReadLine();
}
}
.NET PRECTICALS
46
.NET PRECTICALS
47
28. WAP to implement delegates
using System;
delegate void MCA();
class A
{
public void f1()
{
Console.WriteLine("f1 Method");
}
public void f2()
{
Console.WriteLine("f2 Method");
}
}
class B
{
static void Main()
{
A a1 = new A();
MCA x;
x = a1.f1;
x += a1.f2;
x();
Console.Read();
}
}
.NET PRECTICALS
48
29. WAP to implement multicast delegates
using System;
public delegate void MCA();
class Deltest
{
public void a()
{
Console.WriteLine("Single Delegate");
}
public void b()
{
Console.WriteLine("Multicast Delegate");
}
}
class Program
{
static void Main(string[] args)
{
Deltest dt = new Deltest();
MCA d = new MCA(dt.a);
d += new MCA(dt.b);
d();
Console.ReadKey();
}
}
.NET PRECTICALS
49
30. WAP for displaying Data Handling Application
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
public partial class DataHandling : Form
{
OdbcConnection con;
OdbcDataAdapter da;
DataSet ds;
OdbcDataReader dr;
OdbcCommand cmd;
private int ID;
public DataHandling()
{
con = new OdbcConnection("DSN=Icon;");
con.Open();
da = new OdbcDataAdapter("Select * From tblItem", con);
ds = new DataSet();
da.Fill(ds);
InitializeComponent();
}
private void cmdShow_Click(object sender, EventArgs e)
{
dgItems.DataSource = ds.Tables[0];
}
private void dgItems_Click(object sender, EventArgs e)
{
txtName.Text = dgItems.CurrentRow.Cells[1].Value.ToString();
txtID.Text = dgItems.CurrentRow.Cells[2].Value.ToString();
ID = (int)dgItems.CurrentRow.Cells[0].Value;
}
private void cmdUpdate_Click(object sender, EventArgs e)
{
cmd = new OdbcCommand("Update tblItem Set Item_Name='" +
txtName.Text.ToString() + "',Item_Code='" + txtID.Text.ToString() + "' Where
Item_ID=" + ID, con);
cmd.ExecuteNonQuery();
}
}
.NET PRECTICALS
50
.NET PRECTICALS
51
31.WAP to use Window Form Application
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace windows_Form_application
{
public partial class MDIContainer : Form
{
private int counter;
public MDIContainer()
{
counter = 0;
InitializeComponent();
}
private void cmdNewForm_Click(object sender, EventArgs e)
{
NewForm nf = new NewForm();
nf.MdiParent = this;
nf.Text = "Form Number .: " + counter.ToString();
counter = counter + 1;
nf.Show();
}
private void cmdChangeColor_Click(object sender, EventArgs e)
{
CDialog.ShowDialog();
this.ActiveMdiChild.BackColor = CDialog.Color;
}
}
}
.NET PRECTICALS
52

More Related Content

What's hot

Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C LabNeil Mathew
 
Categories for the Working C++ Programmer
Categories for the Working C++ ProgrammerCategories for the Working C++ Programmer
Categories for the Working C++ ProgrammerPlatonov Sergey
 
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsDebugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsPlatonov Sergey
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesPriyanka Rana
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaPriyanka Rana
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSESujata Regoti
 
Optimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsOptimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsEdward Willink
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5Jeff Larkin
 
9781285852744 ppt ch08
9781285852744 ppt ch089781285852744 ppt ch08
9781285852744 ppt ch08Terry Yoast
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12Aditi Bhushan
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learningMax Kleiner
 
9781285852744 ppt ch16
9781285852744 ppt ch169781285852744 ppt ch16
9781285852744 ppt ch16Terry Yoast
 
C programming session 04
C programming session 04C programming session 04
C programming session 04Vivek Singh
 

What's hot (18)

Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
 
Categories for the Working C++ Programmer
Categories for the Working C++ ProgrammerCategories for the Working C++ Programmer
Categories for the Working C++ Programmer
 
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsDebugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template Metaprograms
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
 
Optimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsOptimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc results
 
Java codes
Java codesJava codes
Java codes
 
Concept of c
Concept of cConcept of c
Concept of c
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
 
9781285852744 ppt ch08
9781285852744 ppt ch089781285852744 ppt ch08
9781285852744 ppt ch08
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learning
 
Matlab file
Matlab fileMatlab file
Matlab file
 
9781285852744 ppt ch16
9781285852744 ppt ch169781285852744 ppt ch16
9781285852744 ppt ch16
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
Java -lec-5
Java -lec-5Java -lec-5
Java -lec-5
 

Viewers also liked

Viewers also liked (20)

Finemore
FinemoreFinemore
Finemore
 
TDeX Computer, Tradex Informática.
TDeX Computer, Tradex Informática.TDeX Computer, Tradex Informática.
TDeX Computer, Tradex Informática.
 
Firestarter Intro.Pps
Firestarter Intro.PpsFirestarter Intro.Pps
Firestarter Intro.Pps
 
QUADRILATERALS
QUADRILATERALSQUADRILATERALS
QUADRILATERALS
 
Globe exploration heb
Globe exploration hebGlobe exploration heb
Globe exploration heb
 
Shemen
ShemenShemen
Shemen
 
Corporate Metabolism
Corporate MetabolismCorporate Metabolism
Corporate Metabolism
 
Harsanyi_Portfilo2001-2010
Harsanyi_Portfilo2001-2010Harsanyi_Portfilo2001-2010
Harsanyi_Portfilo2001-2010
 
Alpha 2012
Alpha 2012Alpha 2012
Alpha 2012
 
南理工2012年研究生招生简章
南理工2012年研究生招生简章南理工2012年研究生招生简章
南理工2012年研究生招生简章
 
Biofeedback alapú interakciók
Biofeedback alapú interakciókBiofeedback alapú interakciók
Biofeedback alapú interakciók
 
Dolgok Allasa - Veszprem 2014
Dolgok Allasa - Veszprem 2014Dolgok Allasa - Veszprem 2014
Dolgok Allasa - Veszprem 2014
 
Arterylite
ArteryliteArterylite
Arterylite
 
Demo
DemoDemo
Demo
 
Chasing Egregors
Chasing EgregorsChasing Egregors
Chasing Egregors
 
Shemen
ShemenShemen
Shemen
 
Pengeélen
 Pengeélen  Pengeélen
Pengeélen
 
Arduino Prezi (BKF)
Arduino Prezi (BKF)Arduino Prezi (BKF)
Arduino Prezi (BKF)
 
480 sensors
480 sensors480 sensors
480 sensors
 
Spe prms
Spe prmsSpe prms
Spe prms
 

Similar to Net practicals lab mannual

Similar to Net practicals lab mannual (20)

39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
Java final lab
Java final labJava final lab
Java final lab
 
C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
C#.net
C#.netC#.net
C#.net
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Hems
HemsHems
Hems
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
APSEC2020 Keynote
APSEC2020 KeynoteAPSEC2020 Keynote
APSEC2020 Keynote
 
JavaProgrammingManual
JavaProgrammingManualJavaProgrammingManual
JavaProgrammingManual
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
CSE215_Module_02_Elementary_Programming.ppt
CSE215_Module_02_Elementary_Programming.pptCSE215_Module_02_Elementary_Programming.ppt
CSE215_Module_02_Elementary_Programming.ppt
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
 
Data Structure Radix Sort
Data Structure Radix SortData Structure Radix Sort
Data Structure Radix Sort
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 

Recently uploaded (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 

Net practicals lab mannual

  • 1. .NET PRECTICALS 1 UTTRANCHAL INSTITUTE OF MANAGEMENT PACTICAL REPORT ON C# DOT NET MASTER of COMPUTER APPLICATION SubmittedTo:- SubmittedBy:-
  • 2. .NET PRECTICALS 2 Rahul singh Abhishek kr pathak UIM, Dehradun MCA4th SEM, UIM,Dehradun
  • 3. .NET PRECTICALS 3 List of Programs Serial Number Name of the program Remark 1 Write a program to display a hello/welcome message 2 WAP for Demonstrating Data Type Conversion 3 WAP for Demonstrating String Handling 4 Given the radius of the circle, WAP to compute the area of the circle, circumference of the circle and display their value. 5 Admission to a professional course is subject to the following cond Mks in maths>=80;Mks in Physics>=75;Mks in chem.>=60; Total Mks all three>=250 or total in maths and physics>= 180 Given the details about the mks, WAP to process the applications to list the eligible candidates. 6 WAP that will read the value of x and evaluate the following function Y= { 1 for x > 0; 0 for x = 0; -1 for x < 0 } Using a) nested if statements b) else if statements and c) conditional operators? 7 shown below is the Floyd’s triangle 1 23 456 78910 . . . 79………….91 WAP to print this triangle. 8 WAP to produce the following patterns * $$$$ 1 ** $$$ 22 *** $$ 333 **** $ 4444 9 WAP to generate and then sum the Fibonacci series 10 Demonstrate the typical use of the following jump statements:  break  continue
  • 4. .NET PRECTICALS 4 In a single program 11 WAP for Declaring Class and invokeing a method. 12 WAP to explain the concept of boxing and unboxing 13 WAP to demonstrate the addition of byte type of variables 14 WAP for using System.Collection Namespace 15 WAP for Implementing Jagged Arrays 16 Given the two one-dimensional arrays A and B which are sorted in ascending order. WAP to merge them into a single sorted array C that contains every items from arrays A and B in ascending order 17 WAP for Using Reflection Class 18 WAP for Using GDI+ Classess 19 WAP for Displaying Constructors and Destructors 20 WAP to implement Single inheritance 21 WAP to implement MultiLevel inheritance 22 WAP to implement Polymorphism 23 WAP to implement Operator Overloading 24 WAP to deal with Exception Handling 25 WAP fo displaying Randomly Generated button and Click Event 26 WAP to Demonstrate Multi Threading Example 27 WAP to implement delegates 28 WAP to implement multicast delegates 29 WAP for displaying Data Handling Application 30 WAP to use Window Form Application 31 Design and develop application as of your own choice
  • 5. .NET PRECTICALS 5 1.Write a program to display a hello/welcome message using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Console.Write("Welcome MCA in UIM"); Console.ReadKey(); } } }
  • 6. .NET PRECTICALS 6 2. WAP for Demonstrating Data Type Conversion using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { string str1 = "123.45"; Single sngl1 = Convert.ToSingle(str1); int x = Convert.ToInt16(sngl1); Console.WriteLine("Single 1 = {0}", sngl1); Console.WriteLine("Integer 1 = {0}", x); double y = Convert.ToDouble(str1); Console.WriteLine("Double = {0}", y); Int16 z = Convert.ToInt16(y); Console.WriteLine("Int16 = {0}", z); Console.ReadLine(); } } }
  • 7. .NET PRECTICALS 7 3.. WAP for Demonstrating String Handling using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace String_Handling { class Program { static void Main(string[] args) { String s1 = "preeti shahi"; String s2 = s1.Insert(2, "i"); Console.WriteLine(s2); String s3 = "preeti shahi"; Boolean b = s3.Equals(s1); Console.WriteLine(b.ToString()); Console.WriteLine(s1.ToLower()); Console.WriteLine(s1.ToUpper()); String s4 = s1.Substring(5); Console.WriteLine(s4); Console.ReadKey(); } } }
  • 8. .NET PRECTICALS 8 4 . Given the radius of the circle, WAP to compute the area of the circle, circumference of the circle and display their value. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Circle { class Program { static void Main(string[] args) { const double pi = 3.14; Console.WriteLine("Enter the radius of the circle"); double r = Convert.ToDouble(Console.ReadLine()); double area = pi * r * r; Console.WriteLine("Area is:" + area.ToString()); double curc = 2 * pi * r; Console.WriteLine("Circumference is:" + curc.ToString()); Console.ReadKey(); } }
  • 9. .NET PRECTICALS 9 5.Admission to a professional course is subject to the following cond Mks in maths>=80;Mks in Physics>=75;Mks in chem.>=60; Total Mks all three>=250 or total in maths and physics>= 180 Given the details about the mks, WAP to process the applications to list the eligible candidates. using System; class Program { static void Main(string[] args) { Console.WriteLine("Enter the marks of Maths,Physics and Chemistry"); int Math = int.Parse(Console.ReadLine()); int Phys = int.Parse(Console.ReadLine()); int Chem = int.Parse(Console.ReadLine()); int total = Math + Phys + Chem; int MP = Math + Phys; if (total >= 250 || MP >= 180) { if (Math >= 80 && Phys >= 75 && Chem >= 60) { Console.WriteLine("Candidates is Eligible"); } else { Console.WriteLine("Candidates is not Eligible"); } } else { Console.WriteLine("Candidates is not Eligible"); } Console.ReadKey(); } }
  • 11. .NET PRECTICALS 11 6.WAP that will read the value of x and evaluate the following function Y= { 1 for x > 0; 0 for x = 0; -1 for x < 0 } Using a) nested if statements b) else if statements and c) conditional operators? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Evaluate_x { class Program { static void Main(string[] args) { Console.WriteLine("Enter the value of X"); int x = int.Parse(Console.ReadLine()); int y = 0; //Using Nested If Statement if (x > 0) { y = 1; } else if (x == 0) { y = 0; } else if (x < 0) { y = -1; } Console.WriteLine("Using else-if Statement:" + y.ToString()); y = (x == 0) ? 0 : (x > 0) ? 1 : (x < 0) ? -1 : 0; Console.WriteLine("Using Conditional Operation:" + y.ToString()); Console.ReadKey(); } } }
  • 13. .NET PRECTICALS 13 7. shown below is WAP to show the Floyd’s triangle on the basis of rows using System; class Program { static void Main(string[] args) { int n, i, c, a = 1; Console.WriteLine("Enter the number of rows till you want to print"); n = int.Parse(Console.ReadLine()); for (i = 1; i <= n; i++) { for (c = 1; c <= i; c++) { Console.Write(a.ToString()); a++; } Console.WriteLine(); } Console.ReadKey(); } }
  • 14. .NET PRECTICALS 14 8. shown below is the Floyd’s triangle 1 23 456 78910 . . . 79………….91 WAP to print this triangle. using System; class Program { static void Main(string[] args) { int n, i, c, a = 1; bool k = true; Console.WriteLine("Enter the number till you want to print"); n = int.Parse(Console.ReadLine()); for (i = 1; i <= n; i++) { for (c = 1; c <= i; c++) { if(a==n) { k=false; break; } Console.Write( a.ToString()); a++; } if (k == false) { break; } Console.WriteLine(); } Console.ReadKey(); } }
  • 16. .NET PRECTICALS 16 9.WAP to produce the following patterns * $$$$ 1 ** $$$ 22 . *** $$ 333 **** $ 4444 using System; class Program { static void Main(string[] args) { int n, c, k; Console.WriteLine("Enter The Number Of Rows"); n = int.Parse(Console.ReadLine()); //Number Tirangle for (c = 1; c <= n; c++) { for (k = 1; k <= c; k++) { Console.Write(c); } Console.WriteLine(); } Console.WriteLine(); //Dollar Tirangle for (c = 1; c <= n; c++) { for (k = 1; k <= c; k++) { Console.Write("$"); } Console.WriteLine(); } Console.WriteLine(); // Star Traingle for (c = n; c >= 1; c--) { for (k = 1; k <= c; k++) { Console.Write("*"); } Console.WriteLine(); } Console.ReadKey(); } }
  • 18. .NET PRECTICALS 18 10..WAP to generate and then sum the fibonacci series:- using System; class Program { static void Main(string[] args) { Console.WriteLine("Enter the terms in Fibonacci series:-"); int n = int.Parse(Console.ReadLine()); int a = -1, b = 1, c = 0, sum = 0; for (int i = 1; i <= n; i++) { c = a + b; sum = sum + c; a = b; b = c; } Console.WriteLine(sum.ToString()); Console.ReadKey(); } }
  • 19. .NET PRECTICALS 19 11. Demonstrate the typical use of the following jump statements:  break  continue In a single program using System; class Program { static void Main(string[] args) { //Continue Statement for (int i = 0; i <= 15; i++) { if (i == 5) { continue; } Console.Write(i.ToString() + " "); } Console.WriteLine(); //Break Statement for (int i = 0; i <= 15; i++) { if (i == 10) { break; } Console.Write(i.ToString() + " "); } Console.ReadKey(); } }
  • 21. .NET PRECTICALS 21 12.WAP for Declaring Class and invoking a method. using System; class Rect { int l, b; public Rect(int l, int b) { this.l = l; this.b = b; } public int getArea() { return l * b; } } class Program { static void Main(string[] args) { Rect a = new Rect(28, 15); Console.WriteLine("Area of rectangle is : " + a.getArea().ToString()); Console.ReadKey(); } }
  • 22. .NET PRECTICALS 22 13.WAP to explain the concept of boxing and un boxing using System; class Program { static void Main(string[] args) { int i = 123; object o = i;//Boxing Console.WriteLine("Boxing OK"); int j = (int)o; //UnBoxing System.Console.WriteLine("Unboxing OK"); try { int k = (short)o;//InvalidCastException Generated System.Console.WriteLine("Unboxing OK"); } catch (System.InvalidCastException e) { System.Console.WriteLine("Incorrect Unboxing.", e.Message); } Console.ReadKey(); } }
  • 23. .NET PRECTICALS 23 14.WAP to demonstrate the addition of byte type of variables:- using System; class Program { static void Main(string[] args) { byte b1 = 88; byte b2 = 79; //byte sum = b1 + b2; error cannot implicitly convert int to byte int sum = b1 + b2; //No error Console.WriteLine(sum.ToString()); Console.ReadKey(); } }
  • 24. .NET PRECTICALS 24 15. WAP for using System.Collection Namespace using System; using System.Collections; namespace system.collection_array_list { class Program { static void Main(string[] args) { ArrayList n = new ArrayList(); n.Add("Preeti Shahi"); n.Add("Yamini Bisht"); n.Add("Gaurav Sharma"); n.Add("Sachin Sisodia"); n.Add("Abhishek Sharma"); n.Add("Abhishek Pathak"); Console.WriteLine("Capacity=" + n.Capacity); Console.WriteLine("Element present=" + n.Count); for (int i = 0; i < n.Count; i++) { Console.Write(n[i] + " "); } Console.WriteLine(); //Sorting Array List n.Sort(); for (int i = 0; i < n.Count; i++) { Console.Write(n[i] + " "); } Console.WriteLine(); //Removing An element n.RemoveAt(2); for (int i = 0; i < n.Count; i++) { Console.Write(n[i] + " "); } Console.ReadKey(); } } }
  • 26. .NET PRECTICALS 26 16.WAP for Implementing Jagged Arrays using System; class Program { static void Main(string[] args) { const int rows = 3; int[][] jagArr = new int[rows][]; jagArr[0] = new int[2]; jagArr[1] = new int[3]; jagArr[2] = new int[4]; jagArr[0][1] = 67; jagArr[1][0] = 83; jagArr[1][1] = 57; jagArr[2][0] = 63; jagArr[2][3] = 14; for (int i = 0; i < 2; i++) { Console.Write(jagArr[0][i] + " "); for (int j = 0; j < 3; j++) { Console.Write(jagArr[1][j] + " "); for (int k = 0; k < 4; k++) { Console.Write(jagArr[2][k] + " "); } Console.WriteLine(); } Console.WriteLine(); } Console.ReadKey(); } }
  • 28. .NET PRECTICALS 28 17. Given the two one-dimensional arrays A and B which are sorted in ascending order. WAP to merge them into a single sorted array C that contains every items from arrays A and B in ascending order using System; class Program { static void Main(string[] args) { int[] a = { 10, 20, 30, 40, 50, 60, 70, 80, 90 }; int[] b = { 18, 36, 54, 72, 90, 108, 126, 144, 120 }; int[] c = new int[a.Length + b.Length]; //Mearging To New Array C a.CopyTo(c, 0); b.CopyTo(c, a.Length); //Sorting Array C for (int i = 0; i < c.Length; i++) { for (int j = i + 1; j < c.Length; j++) { if (c[i] > c[j]) { int temp = c[i]; c[i] = c[j]; c[j] = temp; } } } for (int i = 0; i < c.Length; i++) { Console.WriteLine(c[i]); } Console.ReadKey(); } }
  • 30. .NET PRECTICALS 30 18. WAP for Using Reflection Class using System; using System.Reflection; namespace Wap_To_Reflection { class Program { static void Main(string[] args) { Type t = typeof(System.String); ConstructorInfo[] ci = t.GetConstructors(); Console.WriteLine("Constructors are"); foreach (ConstructorInfo ctemp in ci) { Console.WriteLine(ctemp.ToString()); } Console.WriteLine(); Console.WriteLine("Methods are"); MethodInfo[] mifo = t.GetMethods(); foreach (MethodInfo mifot in mifo) { Console.WriteLine(mifot.ToString()); } Console.ReadKey(); } } }
  • 31. .NET PRECTICALS 31 19. WAP for Using GDI+ Classes using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication6 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Graphics g = CreateGraphics(); Color forecolor = Color.Black; Color backcolor = Color.White; Font font = new Font("Algerian", 26); g.FillRectangle(new SolidBrush(backcolor), ClientRectangle); g.DrawString("Hello friends … m VICKY", font, new SolidBrush(forecolor), 15, 15); Pen myPen = new Pen(new SolidBrush(forecolor), 2); Point p1 = new Point(40); Point p2 = new Point(90); g.DrawRectangle(myPen, 50, 150, 100, 50); g.DrawEllipse(myPen, 100, 50, 80, 40); g.FillEllipse(Brushes.Black, 100, 50, 80, 40); } } }
  • 33. .NET PRECTICALS 33 20. WAP for Displaying Constructors and Destructors using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Constructor_and_Distructor { class Rect { private int l, b; public Rect(int l, int b) { Console.WriteLine("Constructor Call"); this.l = l; this.b = b; } public int area() { return l * b; } Rect() { Console.WriteLine("Destructor call"); } } class Program { static void Main(string[] args) { Rect r = new Rect(32, 24); Console.WriteLine(r.area().ToString()); Console.ReadKey(); } } }
  • 35. .NET PRECTICALS 35 21. WAP to implement Single inheritance using System; class Item { public void x() { Console.WriteLine("Item Code=***"); } } class Fruit : Item { public void type() { Console.WriteLine("Fruit type = Mango"); } } class SingleInheritance { static void Main(string[] args) { Item item = new Item(); Fruit fruit = new Fruit(); item.x(); fruit.type(); Console.ReadKey(); } }
  • 36. .NET PRECTICALS 36 22. WAP to implement MultiLevel inheritance using System; class Student { public string name; public int age; public Student(string name, int age) { this.name = name; this.age = age; } } class Player : Student { public string sport; public string team; public Player(string sport, string team, string name, int age) : base(name, age) { this.sport = sport; this.team = team; } } class CricketPlayer : Player { public int runs; public CricketPlayer(int runs, string sport, string team, string name, int age) : base(sport, team, name, age) { this.runs = runs; } public void Show() { Console.WriteLine("Player:" + name); Console.WriteLine("Age:" + age); Console.WriteLine("Sport:" + sport); Console.WriteLine("Team:" + team); Console.WriteLine("Runs:" + runs); } } class Program { static void Main(string[] args) { CricketPlayer u = new CricketPlayer(210, "Cricket", "India", "Sachin Tendulkar", 43); u.Show(); Console.ReadKey(); } }
  • 38. .NET PRECTICALS 38 23. WAP to implement Polymorphism using System; class Fruit { public virtual void display() { Console.WriteLine("Seasonal Fruits"); } } class SeasonalFruit : Fruit { public override void display() { Console.WriteLine("Seasonal Fruit:Mango"); } } class NonSeasonalFruit : Fruit { public override void display() { Console.WriteLine("NonSeasonal Fruit:Grapes"); } } class InclusionPolymorphism { static void Main(string[] args) { Fruit m = new Fruit(); m = new SeasonalFruit();//Upcasting m.display(); m = new NonSeasonalFruit();//Upcasting m.display(); Console.ReadKey(); } }
  • 40. .NET PRECTICALS 40 24. WAP to implement Operator Overloading using System; class A { int a, b; public void input(int x, int y) { a = x; b = y; } public void output() { Console.WriteLine(a + " " + b); } public static A operator +(A a1, A a2)//Binary Operator OverLoad(+) { A a3 = new A(); a3.a = a1.a + a2.a; a3.b = a1.b + a2.b; return a3; } } class B { static void Main() { A a1 = new A(); A a2 = new A(); A a3 = new A(); a1.input(38, 46); a1.output(); a2.input(40, 59); a2.output(); a3 = a1 + a2; a3.output(); Console.Read(); } }
  • 42. .NET PRECTICALS 42 25. WAP to deal with Exception Handling using System; class A { static void Main() { try { int a, b, c; Console.WriteLine("Enter a and b:"); a = int.Parse(Console.ReadLine()); b = int.Parse(Console.ReadLine()); c = a / b; Console.WriteLine("Output is" + c); } catch (Exception e) { Console.WriteLine("Divide by zero is an error"); } Console.Read(); } }
  • 43. .NET PRECTICALS 43 26. WAP for displaying Randomly Generated button and Click Event using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Randomly_Generated_Button { public partial class RandomGenBt : Form { private Button b1; private int counter1,counter2; public RandomGenBt() { counter1 = 25; counter2 = 25; InitializeComponent(); } private void cmdGen_Click(object sender, EventArgs e) { b1 = new Button(); b1.Location = new Point(counter1, counter2); b1.Size = new Size(50, 25); b1.Text = counter1.ToString() + " " + counter2.ToString(); b1.Click+=new EventHandler(x); this.Controls.Add(b1); counter1 = counter1 + 52; counter2 = counter2 + 27; } private void x(object sender,EventArgs e) { MessageBox.Show(b1.Text.ToString()); } } }
  • 45. .NET PRECTICALS 45 27. WAP to Demonstrate Multi Threading Example using System; using System.Collections.Generic; using System.Threading; class Program { static void Main(string[] args) { // creating more than one thread in the application Thread FirstThread = new Thread(FirstFunction); Thread SecondThread = new Thread(SecondFunction); Thread ThirdThread = new Thread(ThirdFunction); Console.WriteLine("nThreading Starts...n"); //Starting more than one thread in the application FirstThread.Start(); SecondThread.Start(); ThirdThread.Start(); } public static void FirstFunction() { for (int number = 1; number <= 5; number++) { Console.WriteLine("First Thread Displays: " + number); Thread.Sleep(200); } } public static void SecondFunction() { for (int number = 1; number <= 5; number++) { Console.WriteLine("Second Thread Displays: " + number); Thread.Sleep(500); } } public static void ThirdFunction() { for (int number = 1; number <= 5; number++) { Console.WriteLine("Third Thread Displays: " + number); Thread.Sleep(700); } Console.Write("nPress ENTER to quit..."); Console.ReadLine(); } }
  • 47. .NET PRECTICALS 47 28. WAP to implement delegates using System; delegate void MCA(); class A { public void f1() { Console.WriteLine("f1 Method"); } public void f2() { Console.WriteLine("f2 Method"); } } class B { static void Main() { A a1 = new A(); MCA x; x = a1.f1; x += a1.f2; x(); Console.Read(); } }
  • 48. .NET PRECTICALS 48 29. WAP to implement multicast delegates using System; public delegate void MCA(); class Deltest { public void a() { Console.WriteLine("Single Delegate"); } public void b() { Console.WriteLine("Multicast Delegate"); } } class Program { static void Main(string[] args) { Deltest dt = new Deltest(); MCA d = new MCA(dt.a); d += new MCA(dt.b); d(); Console.ReadKey(); } }
  • 49. .NET PRECTICALS 49 30. WAP for displaying Data Handling Application using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.Odbc; public partial class DataHandling : Form { OdbcConnection con; OdbcDataAdapter da; DataSet ds; OdbcDataReader dr; OdbcCommand cmd; private int ID; public DataHandling() { con = new OdbcConnection("DSN=Icon;"); con.Open(); da = new OdbcDataAdapter("Select * From tblItem", con); ds = new DataSet(); da.Fill(ds); InitializeComponent(); } private void cmdShow_Click(object sender, EventArgs e) { dgItems.DataSource = ds.Tables[0]; } private void dgItems_Click(object sender, EventArgs e) { txtName.Text = dgItems.CurrentRow.Cells[1].Value.ToString(); txtID.Text = dgItems.CurrentRow.Cells[2].Value.ToString(); ID = (int)dgItems.CurrentRow.Cells[0].Value; } private void cmdUpdate_Click(object sender, EventArgs e) { cmd = new OdbcCommand("Update tblItem Set Item_Name='" + txtName.Text.ToString() + "',Item_Code='" + txtID.Text.ToString() + "' Where Item_ID=" + ID, con); cmd.ExecuteNonQuery(); } }
  • 51. .NET PRECTICALS 51 31.WAP to use Window Form Application using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace windows_Form_application { public partial class MDIContainer : Form { private int counter; public MDIContainer() { counter = 0; InitializeComponent(); } private void cmdNewForm_Click(object sender, EventArgs e) { NewForm nf = new NewForm(); nf.MdiParent = this; nf.Text = "Form Number .: " + counter.ToString(); counter = counter + 1; nf.Show(); } private void cmdChangeColor_Click(object sender, EventArgs e) { CDialog.ShowDialog(); this.ActiveMdiChild.BackColor = CDialog.Color; } } }