Santosh Kumar
What is the "this" keyword in C# ?
By Santosh Kumar in ASP.NET on Jun 07 2011
  • Munesh  Sharma
    Jun, 2011 14

    Every technology must have a default constructor. 'this' is a reference variable of default constructor that hold the all reference id of the class. 

    • 0
  • Santosh Kumar
    Jun, 2011 7

    C# supports the keyword "this" which is a reference to the object that called the method. The "this" reference is available within all the member method and always refers to the current instance. It is normally used to distinguish between the local and instance variables that have the same name. The "this" reference is a hidden reference passed to every non-static method of a class. Consider the code -

    class temp {
    int x, y;
    public void setXY(int x, int y) {
    this.x =x;
    this.y =y; } }

    In the assignment statement, this.x and this.y refer to the class member named y and y whereas simple x and y refer to the parameter of the setXY() method.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS