A constructor can invoke/call from base class using the base keyword.
public Manager(int initialdata) : base() //Base contructor without parameter
{
//Add further instructions here.
}
public Manager(int annualSalary):base(annualSalary) //Base contructor with parameter
{
//Add further instructions here.
}
A constructor can invoke/call another constructor in the same object using the this keyword.
//First Contructor
public Employee(int annualSalary)
{
salary = annualSalary;
}
//Second Contructor
public Employee(int weeklySalary, int numberOfWeeks)
: this(weeklySalary * umberOfWeeks) //Call First Contruct after call this method.
{
//Add further instructions here.
}
public Manager(int initialdata) : base() //Base contructor without parameter
{
//Add further instructions here.
}
public Manager(int annualSalary):base(annualSalary) //Base contructor with parameter
{
//Add further instructions here.
}
A constructor can invoke/call another constructor in the same object using the this keyword.
//First Contructor
public Employee(int annualSalary)
{
salary = annualSalary;
}
//Second Contructor
public Employee(int weeklySalary, int numberOfWeeks)
: this(weeklySalary * umberOfWeeks) //Call First Contruct after call this method.
{
//Add further instructions here.
}
No comments:
Post a Comment