Can anyone else explain this, (beginners approach). Thanks..
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Extension Methods are just static methods in static classes that behaves like they were defined in other class.
In the first parameter before the type goes the keyword
thiswich indicates that is an extension method.Example:
This is an extension method on System.String that takes two parameters:
– string s : This is the instance variable
– object otherParameter: You can have as many as you want including none
You can call this method in two ways:
Static way:
Extension Method way
In the second case it works as if the type string has an instance method called ExtensionMethodForStrings. Actually for the compiler the are equivalent.