Posts

Showing posts from December, 2014

EXTENSION METHODS

Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type. For client code written in C# and Visual Basic, there is no apparent difference between calling an extension method and the methods that are actually defined in a type. Extension methods can be used in any type of projects like ASP.Net, MVC, Windows Forms, and WPF etc. Implementation: Create a class with some desired name and place it in any place of the project.  Make sure the namespace of the class should be the root namespace of the project.  Create a static method which a return type and a parameter.  The parameter should be prefixed with “this” keyword. Usage: If any variable that matches with the parameter type of the extension can use the extension methods.  Intelligence w