Extension Methods - first parameter ?

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
 
G

GiJeet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top