Sunday 6 November 2016

Extesnion Method

Extension Method.

An Extension method enables us to add methods to existing types without modifying the original types.

We can say that it extends the functionality of an existing type in .Net

An extension method is static method of static class that can be invoked like as an instance method syntax.

In extension method "this" keyword is used with the first parameter and first parameter will be of type that is extended by extension method. 


Example






Key Points about Extension Method

1. An extension method is static method of static class that can be invoked like as an instance method syntax.

2. An extension method first parameter specifies the type of the extended object, and it is preceded by the "this" Keyword.

3. An extension method couldn't override the existing instance methods.

4. An extension method cannot be used with fields, properties or events.








Hope this information  helpful to you. Thank you for taking time to look at my blog. ----- Syed Sadiq Ali.        



    

No comments: