": this()" explained c# code example
Example: c# this
class Employee
{
private string name;
private string alias;
private decimal salary = 3000.00m;
public Employee(string name, string alias)
{
this.name = name;
this.alias = alias;
}
public void printEmployee()
{
Console.WriteLine("Name: {0}\nAlias: {1}", name, alias);
Console.WriteLine("Taxes: {0:C}", Tax.CalcTax(this));
}
public decimal Salary
{
get { return salary; }
}
}
class Tax
{
public static decimal CalcTax(Employee E)
{
return 0.08m * E.Salary;
}
}
class MainClass
{
static void Main()
{
Employee E1 = new Employee("Mingda Pan", "mpan");
E1.printEmployee();
}
}