Professional Documents
Culture Documents
NET
Console Application: Write a program for string manipulation (Split, Concat, Compare, Equal, Padding, Copy, Duplicate, Replace, IndexOf, SubString) Write a program for calculating age with the help of DateTime Write a program for recursion (Fibonacci & Factorial) Write a program for finding area of different shapes using polymorphism Write a program for function overriding Write a program for Employee Information using Class Write a program for illustrate Inheritance
Windows Forms: 1. 2. 3. 4. 5. 6. Design form to create Calculator Application Design a Logon Form and Validate it Design a form for Digital Clock Design form to select image name from list and display in picture box Design a form to use menus Design a form to connect with database using ADO.NET (List, Insert, update, Delete)
C# programs
Console Application:
Console.Write("Enter a number to get factorial : "); i = Convert.ToInt32(Console.ReadLine()); Console.Write("Factorial of {0} is {1}", i, fact(i)); Console.ReadLine(); } static int fact(int i) { if (i == 1) return 1; else return i * fact(i - 1); } } }
Fibonacci
using using using using System; System.Collections.Generic; System.Linq; System.Text;
namespace ConsoleApplication2
{ class Factorial { static void Main(string[] args) { int i; Console.Write("Enter a number to get fibonacci serias : "); i = Convert.ToInt32(Console.ReadLine()); Console.Write("Fibonacci serail \n"); fib(i); Console.ReadLine(); } static void fib(int i) { int j = 0, n = 0; int k = 1; int temp; Console.Write("{0} {1} ", j, k); while (n <= i) { temp = j + k; Console.Write("{0} ", temp); j = k; k = temp; n++; } } } }
namespace ConsoleApplication2 { class Shape { public void Area(int length) { int Area = length * length; Console.WriteLine("Area of Square is : " + Area); } public void Area(int length,int breadth) { int Area = length * breadth; Console.WriteLine("Area of Rectangle is : " + Area); }
public void Area(double radius) { double Area = 3.14 * radius * radius; Console.WriteLine("Area of Circle is : " + Area); } } public class DerivedClass { static void Main(string[] args) { Shape s=new Shape(); s.Area(15); s.Area(10,20); s.Area(10.5); Console.ReadLine(); } } }
using System;
using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2 { class BaseClass { public void display() { Console.WriteLine("Method from Base Class"); } } class DerivedClass : BaseClass { public void display() { Console.WriteLine("Method from Derived class"); } } public class MainClass { static void Main(string[] args) { DerivedClass d = new DerivedClass(); BaseClass b = new BaseClass(); d.display(); b.display(); Console.ReadLine(); } } }
namespace ConsoleApplication2 { class BaseClass { public void display() { Console.WriteLine("Method from Base Class"); } public void Area() { int radius; Console.WriteLine("Enter radius of circle : "); radius = Convert.ToInt32(Console.ReadLine()); double Area = 3.14 * radius * radius;
Console.WriteLine("Area of Circle is : " + Area); } } class DerivedClass : BaseClass { public void AreaofRect() { int length, breadth; Console.WriteLine("Enter length and breadth of rectangle : "); length = Convert.ToInt32(Console.ReadLine()); breadth = Convert.ToInt32(Console.ReadLine()); int Area = length * breadth; Console.WriteLine("Area of Rectangle is : " + Area); } } class MainClass { static void Main(string[] args) { DerivedClass d = new DerivedClass(); d.display(); d.Area(); d.AreaofRect(); Console.ReadLine(); } } }
{ Console.WriteLine("\nMultiple Of 4:= " + n); Console.WriteLine("\nsquare of That Multiple:= " + n * n); Console.WriteLine("******"); } } class Test { public static int i; public static void Main(string[] args) { //DEFINATION::::: //Event class,Response class,Test class //in test class numbers moves from 1 to 40 //when 4 or its multiple comes event is triggered //when event is triggered the number and its square is printed int b = 41; int[] a = new int[b]; Response ob = new Response(); Event1 ob2 = new Event1(); ob2.status += new binaldelegate(ob.eventcatch); //Anonymous method ob2.status += delegate (int n) { Console.WriteLine("\nMultiple Of 4:= " + n); Console.WriteLine("\nsquare of That Multiple:= " + n * n); Console.WriteLine("******"); }; for (i = 1; i < b; i++) { a[i] = i; if (a[i] % 4 == 0) { ob2.implement(a[i]); } } Console.ReadLine(); } } }
{ // This is invoked when assigning to Layout instances with the [ ]. if (number >= 0 && number < _values.Length) { // Assign to this element slot in the internal array. _values[number] = value; } } } } class Program { static void Main() { // Create new instance and assign elements in the array through the indexer. Layout layout = new Layout(); layout[1] = "Frank Gehry"; layout[3] = "I. M. Pei"; layout[10] = "Frank Lloyd Wright"; layout[11] = "Apollodorus"; layout[-1] = "Error"; layout[1000] = "Error"; // Read elements through the indexer. string value1 = layout[1]; string value2 = layout[3]; string value3 = layout[10]; string value4 = layout[11]; string value5 = layout[50]; string value6 = layout[-1]; // Write the results. Console.WriteLine(value1); Console.WriteLine(value2); Console.WriteLine(value3); Console.WriteLine(value4); Console.WriteLine(value5); // Is null Console.WriteLine(value6); } } Output Frank Gehry I. M. Pei Frank Lloyd Wright Apollodorus (null) Error
Windows Form: 1. Design a Logon Form and Validate it 2. Design a form to connect with database using ADO.NET (List, Insert, update, Delete)