Create chaining constructor

Rajni.Shekhar
Posted by Rajni.Shekhar under C# category on | Points: 40 | Views : 920
using System;

/// <summary>
/// Summary description for ExConstrChaining
/// </summary>
public class Example
{
string strFirstName;
string strLastName;
string strAddress;

public Example(string FirstName, string LastName, string Address)
{
this.strFirstName = FirstName;
this.strLastName = LastName;
this.strAddress = Address;
}
//another constructor
public Example(string FName, string LName):this(FName,LName,"constructor address")
{
this.strFirstName = FName;
this.strLastName = LName;
}
public string GetData()
{
return "First Name: " + strFirstName + "<br>Last Name: " + strLastName + "<br>Address: " + strAddress;
}

}

Comments or Responses

Login to post response