- namespace CAConstructor
- {
- class Employeee
- {
- int EmpId, EAge;
- string EName, EAddress;
- public class Employee()
- {
- this.EmpId = 101;
- this.EName = "Sandeep";
- this.EAge = 26;
- this.EAddress = "Hyderabad";
- }
- public void DispEmpData()
- {
- Console.WriteLine("Employee Id Is:" + this.EmpId);
- Console.WriteLine("Employee Name Is:" + this.EName);
- Console.WriteLine("Employee Address is:" + this.EAddress);
- Console.WriteLine("Employee Age Is:" + this.EAge);
- }
- class EmployeeDetail
- {
- static void Main(string[] args)
- {
- Employee Emp1 = new Employee();
- Employee Emp2 = new Employee();
- Emp1.DispEmpData();
- Emp2.DispEmpData();
- }
- }
- }
- }
In this code snippet we will learn to write the code for User Defined Constructor in C# programming.
