How to use this keyword in static method

Currently i come across an interview question which is-
 
Can we use this keyword in static method?
 
The answer is no because static method does not need any object to be called, and this keyword always point to a current object of a class.
 
simply if there is no object then how the keyword point to any current object so,we cannot use this  keyword here.
 
 But there is a situation where we can use this keyword in static method, that is EXTENSION METHOD
 
what is extension method? 
 
It is a new approach or concept that has been added in C#3.0 version which allows to add new methods in an existing class without editing the source of the class.
  1. we can use this method mainly to extend the functionality of an existing class.

  2. In extension methods new methods can be added to an existing class without editing the source code of a class, by first defining those methods under a static class and then bind them with the class we require. 
    3. The first parameter of an extension method must be the name of the class prefixed with this keyword to which the      method has to be added, and this parameter is referred as binding parameter which will not be taken into consideration    while invoking the method.
 
so here i am giving an example of this.
 
 
 Thus we can use this keyword in static method.
Ebook Download
View all
Learn
View all