The this keyword refers to the currently executing instance of a class. It is commonly used to access members from within constructors, instance methods, and instance accessors. However, the static member functions do not have a this pointer. For example:
using System;
public class Students
{
public string name;
public string subcode;
//Constructor.
public Students(string name, string subcode)
{
//Use of this keyword to qualify members hidden by similar names.
this.name = name;
this.subcode = subcode;
}
}
The this keyword is used to pass an object as a parameter to other methods. For example:
Cal_Marks(this);
Responses to “The this keyword”