User Defined Constructor Code in C#

  1. namespace CAConstructor   
  2. {  
  3.     class Employeee   
  4.     {  
  5.         int EmpId, EAge;  
  6.         string EName, EAddress;  
  7.         public class Employee()   
  8.         {  
  9.             this.EmpId = 101;  
  10.             this.EName = "Sandeep";  
  11.             this.EAge = 26;  
  12.             this.EAddress = "Hyderabad";  
  13.         }  
  14.         public void DispEmpData()   
  15.         {  
  16.             Console.WriteLine("Employee Id Is:" + this.EmpId);  
  17.             Console.WriteLine("Employee Name Is:" + this.EName);  
  18.             Console.WriteLine("Employee Address is:" + this.EAddress);  
  19.             Console.WriteLine("Employee Age Is:" + this.EAge);  
  20.         }  
  21.         class EmployeeDetail   
  22.         {  
  23.             static void Main(string[] args)   
  24.             {  
  25.                 Employee Emp1 = new Employee();  
  26.                 Employee Emp2 = new Employee();  
  27.                 Emp1.DispEmpData();  
  28.                 Emp2.DispEmpData();  
  29.             }  
  30.         }  
  31.     }  
  32. }