Extension Methods - first parameter ?

  • Thread starter Thread starter GiJeet
  • Start date Start date
G

GiJeet

Hi, just learning extension methods and the first parameter confuses
me. I understand using the this keyword to indicate the class we wish
to extend, but is the first parameter also used to catch something
passed ? Or is is it just to specify the class we wish to extend?
the reason I guess I'm confused is because sometimes a see a variable
after the class name.

TIA
Gi
 
The first parameter of the method is the instance
on which the extension method was used. Just as you would access that
instance using "this" when writing an actual instance method in a class,
you use the named "this" argument (using the name, not the actual word
"this") to access that instance in code in an extension method.

Ahh....got it now. Thanks!

G
 
Back
Top