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;
}
}
}This code snippet is for constructor chaining with example in C#.
