Is extension method = static method returning strongly typed variables or collections?
i read one entry about it saying -- "this" keyword as a static method param tells The compiler that this particular Extension Method should be added to objects of type default .net class.
SO do we need to add "this" keyword for creating extended method or every static method in static class can be called extension method?
Member 3981366 wrote:returning strongly typed variables or collections
Sorry, I don't understand what you mean.
Member 3981366 wrote:do we need to add "this" keyword for creating extended method
Yes, if you want it to be used as an Extension method i.e. the compiler automatically glueing the code for linking the static extension method to the instance object
Member 3981366 wrote:every static method in static class can be called extension method
No, since you cannnot use static methods with instance object. There lies the major inclination of extension methods.
When you use static methods within static class and use "this" keyword then this method known as Extended methods.
specify an extension method you insert the keyword this before the
first method parameter, which indicates to the compiler the type you
want to extend. Note that the method and its class must be static.