Live Webinar: Prompt Engineering: Skill Everyone Must Learn Today
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
User Defined Constructor Code in C#
WhatsApp
Sandeep Kumar
Mar 22
2015
1.8
k
0
2
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();
}
}
}
}
User Defined Constructor Code
Up Next
User Defined Constructor Code in C#