Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Bounty
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
Constructor Chaining With Example In C#
WhatsApp
Soumalya Das
Aug 23
2016
1.1
k
0
1
namespace
Consolepractice {
class
Program {
public
static
void
Main(
string
[] args) {
student on =
new
student(
"Soumalya"
,
"132"
,
"M"
,
"7278283469"
);
Console.ReadKey();
}
}
class
student {
private
string
_name;
private
string
_roll;
private
string
_gender;
private
string
_phn;
public
student() {
Console.WriteLine(
"default"
);
}
public
student(
string
Name):
this
() {
this
._name = Name;
}
public
student(
string
Name,
string
Roll):
this
(Name) {
this
._roll = Roll;
}
public
student(
string
Name,
string
Roll,
string
Gender):
this
(Name, Roll) {
this
._gender = Gender;
}
public
student(
string
Name,
string
Roll,
string
Gender,
string
Phn):
this
(Name, Roll, Gender) {
this
._phn = Phn;
}
}
}
Constructor Chaining
C#
Up Next
Constructor Chaining With Example In C#