0% found this document useful (0 votes)
16 views

Class Cls Employee 44

The document defines a class called ClsEmployee4 with properties for employee ID, name, address, and age. It includes constructors to initialize an object and copy properties from another object. The Main method creates two ClsEmployee4 objects, one by directly calling the constructor and one by passing the first object, and calls the DisplayEmpData method on each object.

Uploaded by

Chaya Mahadev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Class Cls Employee 44

The document defines a class called ClsEmployee4 with properties for employee ID, name, address, and age. It includes constructors to initialize an object and copy properties from another object. The Main method creates two ClsEmployee4 objects, one by directly calling the constructor and one by passing the first object, and calls the DisplayEmpData method on each object.

Uploaded by

Chaya Mahadev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

class ClsEmployee4

{
int EmpId, EAge;
string EName, Eaddress;
public ClsEmployee4()
{
Console.WriteLine("Enter the Employee
Details:-");
this.EmpId =
Convert.ToInt32(Console.ReadLine());
this.EName = Console.ReadLine();
this.Eaddress = Console.ReadLine();
this.EAge = Convert.ToInt32(Console.ReadLine());
}
public ClsEmployee4(ClsEmployee4 ObjTemp)
{
this.EmpId = ObjTemp.EmpId;
this.EName = ObjTemp.EName;
this.Eaddress = ObjTemp.Eaddress;
this.EAge = ObjTemp.EAge;
}
public void DisplayEmpData()
{
Console.WriteLine("Employee Id is:-"+ EmpId);
Console.WriteLine("Employee Name is:-"+ EName);
Console.WriteLine("Employee address
is:-"+Eaddress);
Console.WriteLine("Employee Age is:-"+EAge);
}
}
class Clsconstructor
{
static void Main(string[] args)
{
ClsEmployee4 obj1 = new ClsEmployee4();
ClsEmployee4 obj2 = new ClsEmployee4(obj1);
obj1.DisplayEmpData();
obj2.DisplayEmpData();
Console.Read();
}
}

You might also like