In order to provide a few constructors, we can just do as follow:
public Employee(string firstName, string lastName,
string qualification = "N/A", string middleName = "")
{
FirstName= firstName;
LastName= lastName;
Qualification= qualification;
MiddleName = middleName;
}
Call the constructor as follow:
Employee(“Adil”,”Mughal”);
I am thinking this way is good if we allow optional parameters, so that when we calls the method, we won't keep passing in null values. ^_^
No comments:
Post a Comment