SlideShare a Scribd company logo
1 of 47
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Lab List - 3 : EX.NO-1 CONSTRUCTOR
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace constructorbook
{
class rectangle
{
public int length, width;
public rectangle(int x, int y)
{
length = x;
width = y;
}
public int rectarea()
{
return (length * width);
}
}
class rectanglearea
{
static void Main(string[] args)
{
rectangle rect1 = new rectangle(15, 10);
int area1 = rect1.rectarea();
Console.WriteLine("area1 is" + area1);
Console.ReadLine();
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Lab List - 3 : EX.NO-1(B) CONSTRUCTOROVERLOADING
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace copyconstructor
{
class sample
{
public string param1, param2;
public sample()
{
param1 = "welcome";
param2 = "c# constuctor";
}
public sample(string x, string y)
{
param1 = x;
param2 = y;
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do
{
sample obj = new sample();
sample obj1 = new sample("welcome", "c#");
Console.WriteLine(obj.param1);
Console.WriteLine(obj.param2);
Console.WriteLine(obj1.param1);
Console.WriteLine(obj1.param2);
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.WriteLine("do u want to continue");
ch = int.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Lab List - 3 : EX.NO-2 (A) SINGLE INHERITANCE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace thirdlablist3
{
class shape
{
public int width;
public int height;
public void display()
{
Console.WriteLine("width and height are" + width + "and" + height);
}
}
class triangle : shape
{
public int area()
{
return width * height / 2;
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do{
triangle t1=new triangle();
t1.width=4;
t1.height=4;
Console.WriteLine("area is"+t1.area());
Console.WriteLine("do u want to continue");
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
ch=int.Parse(Console.ReadLine());
Console.ReadLine();
}
while(ch==1);
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-4 (B) HIARECHICAL INHERITANCE
SOURCECODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class principal
{
public void monitor()
{
Console.WriteLine("monitor");
}
}
class teacher:principal
{
public void teach()
{
Console.WriteLine("teach");
}
}
class student : principal
{
public void learn()
{
Console.WriteLine("learn");
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do{
principal g=new principal();
g.monitor();
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
teacher d=new teacher();
d.monitor();
d.teach();
student s=new student();
s.monitor();
s.learn();
Console.WriteLine("do u want to continue");
ch=int.Parse(Console.ReadLine());
Console.ReadLine();
}
while(ch==1);
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-4 (C) MULTIPLE INHERITANCE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication38
{
class shape
{
public void setwidth(int w)
{
width = w;
}
public void setheight(int h)
{
height = h;
}
protected int width;
protected int height;
}
public interface paintcost
{
int getcost(int area);
}
class rectangle : shape, paintcost
{
public int getarea()
{
return (width * height);
}
public int getcost(int area)
{
return area * 70;
}
}
class rectangletester
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
static void Main(string[] args)
{
rectangle rect = new rectangle();
int area;
rect.setwidth(5);
rect.setheight(7);
area = rect.getarea();
Console.WriteLine("total area:{0}", rect.getarea());
Console.WriteLine("total paintcost:{0}", rect.getcost(area));
Console.ReadLine();
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-3(A) POLYMORPHISM OVERRRIDING
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class baseclass
{
public virtual string yourcity()
{
return "new york";
}
}
class derivedclass : baseclass
{
public override string yourcity()
{
return "london";
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do
{
derivedclass obj= new derivedclass();
string city = obj.yourcity();
Console.WriteLine(city);
Console.WriteLine("do u want to continue");
ch = int.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-3(B) POLYMORPHISM OVERLOADING
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class old
{
public void add(string a1, string a2)
{
Console.WriteLine("adding two string:" + a1 + a2);
}
public void add(int a1, int a2)
{
Console.WriteLine("adding two integer:" + a1 + a2);
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do
{
old obj = new old();
obj.add("eswari", "kala");
obj.add(5, 10);
Console.WriteLine("do u want to continue");
ch = int.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Lab List - 3 : EX.NO-3 (C) VIRTUAL METHOD
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class principal
{
public void monitor()
{
Console.WriteLine("monitor");
}
}
class teacher:principal
{
public void teach()
{
Console.WriteLine("teach");
}
}
class student : principal
{
public void learn()
{
Console.WriteLine("learn");
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do{
principal g=new principal();
g.monitor();
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
teacher d=new teacher();
d.monitor();
d.teach();
student s=new student();
s.monitor();
s.learn();
Console.WriteLine("do u want to continue");
ch=int.Parse(Console.ReadLine());
Console.ReadLine();
}
while(ch==1);
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Lab List - 3 : EX.NO-4 SINGLE DELEGATE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace delegate1
{
class Program
{
delegate int add(int a, int b, int c);
delegate int sub(int a,int b);
static add ad=sum;
static sub sb=subt;
static void Main(string[] args)
{
int sum1,sub1;
sum1=ad.Invoke(3,4,5);
sub1=sb.Invoke(100,200);
Console.WriteLine("the sum is:"+sum1);
Console.WriteLine("the sub is:"+sub1);
Console.ReadLine();
}
static int sum(int a,int b,int c)
{
return(a+b+c);
}
static int subt(int a,int b)
{
return(a-b);
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-4(B) MULTICAST DELEGATE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace delegate2
{
delegate void dele(int a,int b);
public class oper
{
public static void add(int a, int b)
{
Console.WriteLine("{0}+{1}={2}", a, b, a + b);
}
public static void sub(int a, int b)
{
Console.WriteLine("{0}-{1}={2}", a, b, a - b);
}
}
class Program
{
static void Main(string[] args)
{
dele del = new dele(oper.add);
del += new dele(oper.sub);
del(4, 2);
del -= new dele(oper.sub);
del(1, 9);
Console.ReadLine();
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-5(A) ERROR AND EXCEPTION HANDLING
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exception
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("EXCEPTION HANDLING");
Console.WriteLine("1.Array index out of bound exceptionn 2.arithmetic
exception n3.number format exceptionn4.array size exception");
Console.WriteLine("Enter the your choice");
int c = int.Parse(Console.ReadLine());
switch (c)
{
case 1:
Console.WriteLine("Array Index Out Of Bounds exception");
try
{
int[] a = new int[3];
int b = 5;
Console.WriteLine("enter the size");
int s = int.Parse(Console.ReadLine());
Console.WriteLine("enter the numbers");
for (int i = 0; i <= s; i++)
{
a[i] = int.Parse(Console.ReadLine());
} int x = a[2] / (b - a[1]);
}
catch (IndexOutOfRangeException e)
{
Console.WriteLine("array indexerror");
}
break;
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
case 2:
Console.WriteLine("arithmetic exception");
try
{
int p = int.Parse(Console.ReadLine());
int q = int.Parse(Console.ReadLine());
int r = p / q;
Console.WriteLine(r);
}
catch (ArithmeticException e)
{
Console.WriteLine("division by zero");
}
break;
case 3:
Console.WriteLine("number for exception");
try
{
int k = int.Parse(Console.ReadLine());
int[] h = new int[k];
Console.WriteLine("ente the float numbers:");
for (int m = 0; m <= k; m++)
{
h[m] = int.Parse(Console.ReadLine());
} }
catch (FormatException e)
{
Console.WriteLine("type mismatch exception");
}
break;
case 4:
Console.WriteLine("Type mismatch exception");
try
{
Console.WriteLine("enter the no to enter");
int x = int.Parse(Console.ReadLine());
double[] y = new double[x];
}
catch (OverflowException e)
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.WriteLine("array type mismatch");
}
break;
case 5:
Console.WriteLine("stack over flow exception");
try
{
int[] a = new int[3];
for (int i = 0; i < 5; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
}
catch (StackOverflowException e)
{
Console.WriteLine("stack overflow exception");
}
break;
}
Console.ReadLine();
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(B)INDEX OUT OF RANGE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exception3
{
class arrayoutofindex
{
public void caldiff()
{
int difference = 0;
int[] number = new int[5] { 1, 2, 3, 4, 5 };
try
{
for (int init = 1; init <= 5; init++)
{
difference = difference - number[init];
}
Console.WriteLine("the difference of the array is:" + difference);
}
catch (IndexOutOfRangeException e)
{
Console.WriteLine(e.Message);
}
}
}
class Program
{
static void Main(string[] args)
{
arrayoutofindex obj= new arrayoutofindex();
obj.caldiff();
Console.ReadLine();
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(C)INNER EXCEPTION
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace exception4
{
public class myappexception : ApplicationException
{
public myappexception(string message): base(message)
{
}
public myappexception(string message, Exception inner)
{
}
}
public class exceptionexample
{
public void throwineer()
{
throw new myappexception("exception example inner exception");
}
public void catchinner()
{
try
{
this.throwineer();
}
catch (Exception e)
{
throw new myappexception("error caused by trying throwinner", e);
}
}
}
class Program
{
static void Main(string[] args)
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
exceptionexample test = new exceptionexample();
try
{
test.catchinner();
}
catch (Exception e)
{
Console.WriteLine("in main catch block.caught:{0}", e.Message);
Console.WriteLine("inner exception is{0}", e.InnerException);
}
Console.ReadLine();
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(D)ARRAY TYPE MISMATCH EXCEPTION
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace keyoutexc
{
class Program
{
static void Main(string[] args)
{
try
{
//
// Create new Dictionary with string key of "one"
//
Dictionary<string, string> test = new Dictionary<string, string>();
test.Add("one", "value");
//
// Try to access key of "two"
//
string value = test["two"];
}
catch (Exception ex)
{
//
// An exception will be thrown.
//
Console.WriteLine(ex);
Console.ReadLine();
}
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(E)KEY OUT OF EXCEPTION
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace keyoutexc
{
class Program
{
static void Main(string[] args)
{
try
{
//
// Create new Dictionary with string key of "one"
//
Dictionary<string, string> test = new Dictionary<string, string>();
test.Add("one", "value");
//
// Try to access key of "two"
//
string value = test["two"];
}
catch (Exception ex)
{
//
// An exception will be thrown.
//
Console.WriteLine(ex);
Console.ReadLine();
}
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-6 MAIN THREAD
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace mythread
{
class Program
{
static void Main(string[] args)
{
Thread th = Thread.CurrentThread;
th.Name = "mainthread";
Console.WriteLine(" this is {0}", th.Name);
Console.ReadLine();
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(B)TIMER THREAD
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace timerthread
{
class Program
{
static void Main(string[] args)
{
System.Threading.Timer thrdtimer = new Timer(run, 3, 0, 1000);
Thread.Sleep(1000);
Console.WriteLine("goodbye!! i am main thread");
Console.ReadLine();
}
static void run(object args)
{
int j = (int)args;
Console.WriteLine("hi i am executing by timer you passed" + j);
}
}}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(C)STARTING THREAD WITH CHILD THREAD
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace threadstartdelegate
{
class Program
{
static void Main(string[] args)
{
{
// Create Thread class object and paas object of ThreadStart delegate with
specified method its constructor
Thread th=new Thread(new ThreadStart(MyMethod));
th.Name="Child thread";
// Start child thread
th.Start();
for (int i=0; i<20; i++)
{
Console.WriteLine("Main Thread");
}
Console.WriteLine("End Thread...");
Console.ReadKey();
}
}
// Method used in thread execution
public static void MyMethod()
{
for (int i=0; i<10; i++)
{
Console.WriteLine("Child Thread");
}
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(D)THREAD STARTED
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace threading
{
class program
{
static void Main(string[] args)
{ //Creating thread object to strat it
Thread th= new Thread(ThreadB);
Console.WriteLine("Threads started :");
// Start thread B
th.Start();
//Thread A executes 10 times
for (int i=0; i<10; i++)
{ Console.WriteLine("Thread : A") }
Console.WriteLine("Threads completed");
Console.ReadKey(); }
public static void ThreadB()
{ //Executes thread B 10 times
for(int i=0;i<10;i++)
{
Console.WriteLine("Thread : B"); } } } }
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-7 STRUCTURES
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace structures
{
class Program
{
struct stu
{
public string name;
public int rollno;
public int mark1;
public int mark2;
public int mark3;
public int mark4;
public int mark5;
public int total;
public float avg;
};
public class testStructure
{ public static void Main(string[] args)
{ stu s1;
/* book1 specification */
s1.name = Console.ReadLine();
s1.rollno = int.Parse(Console.ReadLine());
s1.mark1 = int.Parse(Console.ReadLine());
s1.mark2 = int.Parse(Console.ReadLine());
s1.mark3 = int.Parse(Console.ReadLine());
s1.mark4 = int.Parse(Console.ReadLine());
s1.mark5 = int.Parse(Console.ReadLine());
s1.total = s1.mark1 + s1.mark2 + s1.mark3 + s1.mark4 + s1.mark5;
s1.avg = s1.total / 5;
Console.WriteLine("Total Marks:" + s1.total);
Console.WriteLine("Total average is:" + s1.avg);
Console.ReadLine();
} } } }
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
(B)ENUMERATION
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication42
{
class enumprogram
{
enum days { sun, mon, tue, wed, thu, fri, sat };
static void Main(string[] args)
{
int weekdaystart = (int)days.mon;
int weekdayend = (int)days.fri;
Console.WriteLine("monday:{0}", weekdaystart);
Console.WriteLine("friday:{0}", weekdayend);
Console.ReadLine();
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-8 JAGGED ARRAY
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication39
{
class myarray
{
static void Main(string[] args)
{
int[][] a = new int[][] { new int[] { 0, 0 }, new int[] { 1, 2 }, new int[] { 2, 4
}, new int[] { 3, 6 }, new int[] { 4, 8 } };
int i, j;
for (i = 0; i < 5; i++)
{
for (j = 0; j < 2; j++)
{ Console.WriteLine("a[{0}][{1}]={2}", i, j, a[i][j]);
} }
Console.ReadLine(); } } }
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 3 : EX.NO-9 ABSTRACT
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace abstractprogram
{
class Program
{
abstract class ShapesClass
{
abstractpublic int Area();
}
class Square : ShapesClass
{
int side = 0;
public Square(int n)
{
side = n;
}
// Area method is required to avoid
// a compile-time error.
public override int Area()
{
return side * side;
}
static void Main(string[] args)
{
Square sq = new Square(12);
Console.WriteLine("Area of the square = {0}", sq.Area());
Console.ReadLine();
}
interface I
{
void M();
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
abstract class C : I
{
public abstract void M();
}
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST:3 EXNO-10 STUDENT MARKSTATEMENT
DESIGN:
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 thirdlablist
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
private void button1_Click_1(object sender, EventArgs e)
{
textBox6.Text = ((Convert.ToDouble(textBox1.Text) +
Convert.ToDouble(textBox2.Text) + Convert.ToDouble(textBox3.Text) +
Convert.ToDouble(textBox4.Text) +
Convert.ToDouble(textBox5.Text))).ToString();
}
private void button2_Click(object sender, EventArgs e)
{
textBox7.Text = (Convert.ToDouble(textBox6.Text) / 5).ToString();
}
private void button3_Click(object sender, EventArgs e)
{
double n;
n = Convert.ToDouble(textBox7.Text);
if ((n >= 90))
{
textBox8.Text = "O";
}
else if ((n >= 80) && (n < 90))
{
textBox8.Text = "A";
}
else if ((n >= 60) && (n < 80))
{
textBox8.Text = "B";
}
else if ((n >= 40) && (n < 60))
{
textBox8.Text = "D";
}
else
{
textBox8.Text = "C";
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
}
}
private void button4_Click(object sender, EventArgs e)
{
textBox9.Text = "eswari 06-09-1994";
}
private void button5_Click(object sender, EventArgs e)
{
textBox10.Text = "SDA SCHOOL FIRST CLASS";
}
private void button6_Click(object sender, EventArgs e)
{
textBox11.Text = "14274104";
}
private void Form1_Load(objectsender, EventArgs e)
{
}
}
}
class MApplication
{
public static void main()
{
Application.Run(new Form());
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:

More Related Content

What's hot

Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8Alex Tumanoff
 
C# console programms
C# console programmsC# console programms
C# console programmsYasir Khan
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Functional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with PythonFunctional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with PythonCarlos V.
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListPTCL
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
Java Generics for Dummies
Java Generics for DummiesJava Generics for Dummies
Java Generics for Dummiesknutmork
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Piotr Paradziński
 
.NET 2015: Будущее рядом
.NET 2015: Будущее рядом.NET 2015: Будущее рядом
.NET 2015: Будущее рядомAndrey Akinshin
 
Java simple programs
Java simple programsJava simple programs
Java simple programsVEERA RAGAVAN
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongMario Fusco
 
Declare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationDeclare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationEelco Visser
 
SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8Chaitanya Ganoo
 

What's hot (19)

Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8
 
C# console programms
C# console programmsC# console programms
C# console programms
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
Programming Homework Help
Programming Homework Help Programming Homework Help
Programming Homework Help
 
Functional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with PythonFunctional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with Python
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Java Generics for Dummies
Java Generics for DummiesJava Generics for Dummies
Java Generics for Dummies
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
 
.NET 2015: Будущее рядом
.NET 2015: Будущее рядом.NET 2015: Будущее рядом
.NET 2015: Будущее рядом
 
Java simple programs
Java simple programsJava simple programs
Java simple programs
 
Java Generics
Java GenericsJava Generics
Java Generics
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are Wrong
 
Declare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationDeclare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code Generation
 
SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8
 
Operating System Assignment Help
Operating System Assignment HelpOperating System Assignment Help
Operating System Assignment Help
 

Similar to .net progrmming part3

Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Distributed systems
Distributed systemsDistributed systems
Distributed systemsSonali Parab
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17LogeekNightUkraine
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 
Attributes & .NET components
Attributes & .NET componentsAttributes & .NET components
Attributes & .NET componentsBình Trọng Án
 
Programimport java.util.Scanner; public class AreaOfRectangle {.pdf
Programimport java.util.Scanner; public class AreaOfRectangle {.pdfProgramimport java.util.Scanner; public class AreaOfRectangle {.pdf
Programimport java.util.Scanner; public class AreaOfRectangle {.pdfhimanshukausik409
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesEelco Visser
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarROHIT JAISWAR
 

Similar to .net progrmming part3 (20)

TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Major Java 8 features
Major Java 8 featuresMajor Java 8 features
Major Java 8 features
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
Java and j2ee_lab-manual
Java and j2ee_lab-manualJava and j2ee_lab-manual
Java and j2ee_lab-manual
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Distributed systems
Distributed systemsDistributed systems
Distributed systems
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 
Hems
HemsHems
Hems
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 
srgoc
srgocsrgoc
srgoc
 
Attributes & .NET components
Attributes & .NET componentsAttributes & .NET components
Attributes & .NET components
 
Programimport java.util.Scanner; public class AreaOfRectangle {.pdf
Programimport java.util.Scanner; public class AreaOfRectangle {.pdfProgramimport java.util.Scanner; public class AreaOfRectangle {.pdf
Programimport java.util.Scanner; public class AreaOfRectangle {.pdf
 
Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 

More from Dr.M.Karthika parthasarathy

IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...Dr.M.Karthika parthasarathy
 
Unit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxUnit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxDr.M.Karthika parthasarathy
 

More from Dr.M.Karthika parthasarathy (20)

IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
 
Linux Lab Manual.doc
Linux Lab Manual.docLinux Lab Manual.doc
Linux Lab Manual.doc
 
Unit 2 IoT.pdf
Unit 2 IoT.pdfUnit 2 IoT.pdf
Unit 2 IoT.pdf
 
Unit 3 IOT.docx
Unit 3 IOT.docxUnit 3 IOT.docx
Unit 3 IOT.docx
 
Unit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxUnit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptx
 
Unit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docxUnit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docx
 
Introduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptxIntroduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptx
 
IoT Unit 2.pdf
IoT Unit 2.pdfIoT Unit 2.pdf
IoT Unit 2.pdf
 
Chapter 3 heuristic search techniques
Chapter 3 heuristic search techniquesChapter 3 heuristic search techniques
Chapter 3 heuristic search techniques
 
Ai mcq chapter 2
Ai mcq chapter 2Ai mcq chapter 2
Ai mcq chapter 2
 
Introduction to IoT unit II
Introduction to IoT  unit IIIntroduction to IoT  unit II
Introduction to IoT unit II
 
Introduction to IoT - Unit I
Introduction to IoT - Unit IIntroduction to IoT - Unit I
Introduction to IoT - Unit I
 
Internet of things Unit 1 one word
Internet of things Unit 1 one wordInternet of things Unit 1 one word
Internet of things Unit 1 one word
 
Unit 1 q&amp;a
Unit  1 q&amp;aUnit  1 q&amp;a
Unit 1 q&amp;a
 
Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1
 
Examples in OS synchronization for UG
Examples in OS synchronization for UG Examples in OS synchronization for UG
Examples in OS synchronization for UG
 
Process Synchronization - Monitors
Process Synchronization - MonitorsProcess Synchronization - Monitors
Process Synchronization - Monitors
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
Java programs
Java programsJava programs
Java programs
 

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
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
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
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
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 

.net progrmming part3

  • 1. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Lab List - 3 : EX.NO-1 CONSTRUCTOR SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace constructorbook { class rectangle { public int length, width; public rectangle(int x, int y) { length = x; width = y; } public int rectarea() { return (length * width); } } class rectanglearea { static void Main(string[] args) { rectangle rect1 = new rectangle(15, 10); int area1 = rect1.rectarea(); Console.WriteLine("area1 is" + area1); Console.ReadLine(); } } }
  • 2. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 3. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Lab List - 3 : EX.NO-1(B) CONSTRUCTOROVERLOADING SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace copyconstructor { class sample { public string param1, param2; public sample() { param1 = "welcome"; param2 = "c# constuctor"; } public sample(string x, string y) { param1 = x; param2 = y; } } class Program { static void Main(string[] args) { int ch; do { sample obj = new sample(); sample obj1 = new sample("welcome", "c#"); Console.WriteLine(obj.param1); Console.WriteLine(obj.param2); Console.WriteLine(obj1.param1); Console.WriteLine(obj1.param2);
  • 4. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.WriteLine("do u want to continue"); ch = int.Parse(Console.ReadLine()); Console.ReadLine(); } while (ch == 1); } } } OUTPUT:
  • 5. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Lab List - 3 : EX.NO-2 (A) SINGLE INHERITANCE SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace thirdlablist3 { class shape { public int width; public int height; public void display() { Console.WriteLine("width and height are" + width + "and" + height); } } class triangle : shape { public int area() { return width * height / 2; } } class Program { static void Main(string[] args) { int ch; do{ triangle t1=new triangle(); t1.width=4; t1.height=4; Console.WriteLine("area is"+t1.area()); Console.WriteLine("do u want to continue");
  • 6. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment ch=int.Parse(Console.ReadLine()); Console.ReadLine(); } while(ch==1); } } } OUTPUT:
  • 7. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-4 (B) HIARECHICAL INHERITANCE SOURCECODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class principal { public void monitor() { Console.WriteLine("monitor"); } } class teacher:principal { public void teach() { Console.WriteLine("teach"); } } class student : principal { public void learn() { Console.WriteLine("learn"); } } class Program { static void Main(string[] args) { int ch; do{ principal g=new principal(); g.monitor();
  • 8. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment teacher d=new teacher(); d.monitor(); d.teach(); student s=new student(); s.monitor(); s.learn(); Console.WriteLine("do u want to continue"); ch=int.Parse(Console.ReadLine()); Console.ReadLine(); } while(ch==1); } } } OUTPUT:
  • 9. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-4 (C) MULTIPLE INHERITANCE SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication38 { class shape { public void setwidth(int w) { width = w; } public void setheight(int h) { height = h; } protected int width; protected int height; } public interface paintcost { int getcost(int area); } class rectangle : shape, paintcost { public int getarea() { return (width * height); } public int getcost(int area) { return area * 70; } } class rectangletester {
  • 10. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment static void Main(string[] args) { rectangle rect = new rectangle(); int area; rect.setwidth(5); rect.setheight(7); area = rect.getarea(); Console.WriteLine("total area:{0}", rect.getarea()); Console.WriteLine("total paintcost:{0}", rect.getcost(area)); Console.ReadLine(); } } } OUTPUT:
  • 11. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-3(A) POLYMORPHISM OVERRRIDING SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication5 { class baseclass { public virtual string yourcity() { return "new york"; } } class derivedclass : baseclass { public override string yourcity() { return "london"; } } class Program { static void Main(string[] args) { int ch; do { derivedclass obj= new derivedclass(); string city = obj.yourcity(); Console.WriteLine(city); Console.WriteLine("do u want to continue"); ch = int.Parse(Console.ReadLine()); Console.ReadLine(); } while (ch == 1); }
  • 12. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment } } OUTPUT:
  • 13. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-3(B) POLYMORPHISM OVERLOADING SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication4 { class old { public void add(string a1, string a2) { Console.WriteLine("adding two string:" + a1 + a2); } public void add(int a1, int a2) { Console.WriteLine("adding two integer:" + a1 + a2); } } class Program { static void Main(string[] args) { int ch; do { old obj = new old(); obj.add("eswari", "kala"); obj.add(5, 10); Console.WriteLine("do u want to continue"); ch = int.Parse(Console.ReadLine()); Console.ReadLine(); } while (ch == 1); } } }
  • 14. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 15. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Lab List - 3 : EX.NO-3 (C) VIRTUAL METHOD SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class principal { public void monitor() { Console.WriteLine("monitor"); } } class teacher:principal { public void teach() { Console.WriteLine("teach"); } } class student : principal { public void learn() { Console.WriteLine("learn"); } } class Program { static void Main(string[] args) { int ch; do{ principal g=new principal(); g.monitor();
  • 16. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment teacher d=new teacher(); d.monitor(); d.teach(); student s=new student(); s.monitor(); s.learn(); Console.WriteLine("do u want to continue"); ch=int.Parse(Console.ReadLine()); Console.ReadLine(); } while(ch==1); } } } OUTPUT:
  • 17. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Lab List - 3 : EX.NO-4 SINGLE DELEGATE SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace delegate1 { class Program { delegate int add(int a, int b, int c); delegate int sub(int a,int b); static add ad=sum; static sub sb=subt; static void Main(string[] args) { int sum1,sub1; sum1=ad.Invoke(3,4,5); sub1=sb.Invoke(100,200); Console.WriteLine("the sum is:"+sum1); Console.WriteLine("the sub is:"+sub1); Console.ReadLine(); } static int sum(int a,int b,int c) { return(a+b+c); } static int subt(int a,int b) { return(a-b); } } }
  • 18. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 19. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-4(B) MULTICAST DELEGATE SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace delegate2 { delegate void dele(int a,int b); public class oper { public static void add(int a, int b) { Console.WriteLine("{0}+{1}={2}", a, b, a + b); } public static void sub(int a, int b) { Console.WriteLine("{0}-{1}={2}", a, b, a - b); } } class Program { static void Main(string[] args) { dele del = new dele(oper.add); del += new dele(oper.sub); del(4, 2); del -= new dele(oper.sub); del(1, 9); Console.ReadLine(); } } }
  • 20. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 21. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-5(A) ERROR AND EXCEPTION HANDLING SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace exception { class Program { static void Main(string[] args) { Console.WriteLine("EXCEPTION HANDLING"); Console.WriteLine("1.Array index out of bound exceptionn 2.arithmetic exception n3.number format exceptionn4.array size exception"); Console.WriteLine("Enter the your choice"); int c = int.Parse(Console.ReadLine()); switch (c) { case 1: Console.WriteLine("Array Index Out Of Bounds exception"); try { int[] a = new int[3]; int b = 5; Console.WriteLine("enter the size"); int s = int.Parse(Console.ReadLine()); Console.WriteLine("enter the numbers"); for (int i = 0; i <= s; i++) { a[i] = int.Parse(Console.ReadLine()); } int x = a[2] / (b - a[1]); } catch (IndexOutOfRangeException e) { Console.WriteLine("array indexerror"); } break;
  • 22. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment case 2: Console.WriteLine("arithmetic exception"); try { int p = int.Parse(Console.ReadLine()); int q = int.Parse(Console.ReadLine()); int r = p / q; Console.WriteLine(r); } catch (ArithmeticException e) { Console.WriteLine("division by zero"); } break; case 3: Console.WriteLine("number for exception"); try { int k = int.Parse(Console.ReadLine()); int[] h = new int[k]; Console.WriteLine("ente the float numbers:"); for (int m = 0; m <= k; m++) { h[m] = int.Parse(Console.ReadLine()); } } catch (FormatException e) { Console.WriteLine("type mismatch exception"); } break; case 4: Console.WriteLine("Type mismatch exception"); try { Console.WriteLine("enter the no to enter"); int x = int.Parse(Console.ReadLine()); double[] y = new double[x]; } catch (OverflowException e) {
  • 23. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.WriteLine("array type mismatch"); } break; case 5: Console.WriteLine("stack over flow exception"); try { int[] a = new int[3]; for (int i = 0; i < 5; i++) { a[i] = int.Parse(Console.ReadLine()); } } catch (StackOverflowException e) { Console.WriteLine("stack overflow exception"); } break; } Console.ReadLine(); } } }
  • 24. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 25. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (B)INDEX OUT OF RANGE SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace exception3 { class arrayoutofindex { public void caldiff() { int difference = 0; int[] number = new int[5] { 1, 2, 3, 4, 5 }; try { for (int init = 1; init <= 5; init++) { difference = difference - number[init]; } Console.WriteLine("the difference of the array is:" + difference); } catch (IndexOutOfRangeException e) { Console.WriteLine(e.Message); } } } class Program { static void Main(string[] args) { arrayoutofindex obj= new arrayoutofindex(); obj.caldiff(); Console.ReadLine(); } } }
  • 26. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 27. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (C)INNER EXCEPTION SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace exception4 { public class myappexception : ApplicationException { public myappexception(string message): base(message) { } public myappexception(string message, Exception inner) { } } public class exceptionexample { public void throwineer() { throw new myappexception("exception example inner exception"); } public void catchinner() { try { this.throwineer(); } catch (Exception e) { throw new myappexception("error caused by trying throwinner", e); } } } class Program { static void Main(string[] args) {
  • 28. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment exceptionexample test = new exceptionexample(); try { test.catchinner(); } catch (Exception e) { Console.WriteLine("in main catch block.caught:{0}", e.Message); Console.WriteLine("inner exception is{0}", e.InnerException); } Console.ReadLine(); } } } OUTPUT:
  • 29. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (D)ARRAY TYPE MISMATCH EXCEPTION SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace keyoutexc { class Program { static void Main(string[] args) { try { // // Create new Dictionary with string key of "one" // Dictionary<string, string> test = new Dictionary<string, string>(); test.Add("one", "value"); // // Try to access key of "two" // string value = test["two"]; } catch (Exception ex) { // // An exception will be thrown. // Console.WriteLine(ex); Console.ReadLine(); } } } }
  • 30. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 31. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (E)KEY OUT OF EXCEPTION SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace keyoutexc { class Program { static void Main(string[] args) { try { // // Create new Dictionary with string key of "one" // Dictionary<string, string> test = new Dictionary<string, string>(); test.Add("one", "value"); // // Try to access key of "two" // string value = test["two"]; } catch (Exception ex) { // // An exception will be thrown. // Console.WriteLine(ex); Console.ReadLine(); } } } }
  • 32. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 33. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-6 MAIN THREAD SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace mythread { class Program { static void Main(string[] args) { Thread th = Thread.CurrentThread; th.Name = "mainthread"; Console.WriteLine(" this is {0}", th.Name); Console.ReadLine(); } } } OUTPUT:
  • 34. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (B)TIMER THREAD SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace timerthread { class Program { static void Main(string[] args) { System.Threading.Timer thrdtimer = new Timer(run, 3, 0, 1000); Thread.Sleep(1000); Console.WriteLine("goodbye!! i am main thread"); Console.ReadLine(); } static void run(object args) { int j = (int)args; Console.WriteLine("hi i am executing by timer you passed" + j); } }} OUTPUT:
  • 35. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (C)STARTING THREAD WITH CHILD THREAD SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace threadstartdelegate { class Program { static void Main(string[] args) { { // Create Thread class object and paas object of ThreadStart delegate with specified method its constructor Thread th=new Thread(new ThreadStart(MyMethod)); th.Name="Child thread"; // Start child thread th.Start(); for (int i=0; i<20; i++) { Console.WriteLine("Main Thread"); } Console.WriteLine("End Thread..."); Console.ReadKey(); } } // Method used in thread execution public static void MyMethod() { for (int i=0; i<10; i++) { Console.WriteLine("Child Thread"); } } } }
  • 36. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 37. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (D)THREAD STARTED SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace threading { class program { static void Main(string[] args) { //Creating thread object to strat it Thread th= new Thread(ThreadB); Console.WriteLine("Threads started :"); // Start thread B th.Start(); //Thread A executes 10 times for (int i=0; i<10; i++) { Console.WriteLine("Thread : A") } Console.WriteLine("Threads completed"); Console.ReadKey(); } public static void ThreadB() { //Executes thread B 10 times for(int i=0;i<10;i++) { Console.WriteLine("Thread : B"); } } } } OUTPUT:
  • 38. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-7 STRUCTURES SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace structures { class Program { struct stu { public string name; public int rollno; public int mark1; public int mark2; public int mark3; public int mark4; public int mark5; public int total; public float avg; }; public class testStructure { public static void Main(string[] args) { stu s1; /* book1 specification */ s1.name = Console.ReadLine(); s1.rollno = int.Parse(Console.ReadLine()); s1.mark1 = int.Parse(Console.ReadLine()); s1.mark2 = int.Parse(Console.ReadLine()); s1.mark3 = int.Parse(Console.ReadLine()); s1.mark4 = int.Parse(Console.ReadLine()); s1.mark5 = int.Parse(Console.ReadLine()); s1.total = s1.mark1 + s1.mark2 + s1.mark3 + s1.mark4 + s1.mark5; s1.avg = s1.total / 5; Console.WriteLine("Total Marks:" + s1.total); Console.WriteLine("Total average is:" + s1.avg); Console.ReadLine(); } } } }
  • 39. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 40. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment (B)ENUMERATION SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication42 { class enumprogram { enum days { sun, mon, tue, wed, thu, fri, sat }; static void Main(string[] args) { int weekdaystart = (int)days.mon; int weekdayend = (int)days.fri; Console.WriteLine("monday:{0}", weekdaystart); Console.WriteLine("friday:{0}", weekdayend); Console.ReadLine(); } } } OUTPUT:
  • 41. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-8 JAGGED ARRAY SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication39 { class myarray { static void Main(string[] args) { int[][] a = new int[][] { new int[] { 0, 0 }, new int[] { 1, 2 }, new int[] { 2, 4 }, new int[] { 3, 6 }, new int[] { 4, 8 } }; int i, j; for (i = 0; i < 5; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("a[{0}][{1}]={2}", i, j, a[i][j]); } } Console.ReadLine(); } } } OUTPUT:
  • 42. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 3 : EX.NO-9 ABSTRACT SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace abstractprogram { class Program { abstract class ShapesClass { abstractpublic int Area(); } class Square : ShapesClass { int side = 0; public Square(int n) { side = n; } // Area method is required to avoid // a compile-time error. public override int Area() { return side * side; } static void Main(string[] args) { Square sq = new Square(12); Console.WriteLine("Area of the square = {0}", sq.Area()); Console.ReadLine(); } interface I { void M(); }
  • 43. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment abstract class C : I { public abstract void M(); } } } } OUTPUT:
  • 44. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST:3 EXNO-10 STUDENT MARKSTATEMENT DESIGN: 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 thirdlablist { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
  • 45. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment private void button1_Click_1(object sender, EventArgs e) { textBox6.Text = ((Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text) + Convert.ToDouble(textBox3.Text) + Convert.ToDouble(textBox4.Text) + Convert.ToDouble(textBox5.Text))).ToString(); } private void button2_Click(object sender, EventArgs e) { textBox7.Text = (Convert.ToDouble(textBox6.Text) / 5).ToString(); } private void button3_Click(object sender, EventArgs e) { double n; n = Convert.ToDouble(textBox7.Text); if ((n >= 90)) { textBox8.Text = "O"; } else if ((n >= 80) && (n < 90)) { textBox8.Text = "A"; } else if ((n >= 60) && (n < 80)) { textBox8.Text = "B"; } else if ((n >= 40) && (n < 60)) { textBox8.Text = "D"; } else { textBox8.Text = "C";
  • 46. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment } } private void button4_Click(object sender, EventArgs e) { textBox9.Text = "eswari 06-09-1994"; } private void button5_Click(object sender, EventArgs e) { textBox10.Text = "SDA SCHOOL FIRST CLASS"; } private void button6_Click(object sender, EventArgs e) { textBox11.Text = "14274104"; } private void Form1_Load(objectsender, EventArgs e) { } } } class MApplication { public static void main() { Application.Run(new Form()); } }
  • 47. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT: