Extension methods are methods that can be created extending existing types without the need to inherit from a class and creating your own custom logic. It can also be applied on interfaces.
From MSDN:
Extension methods enable you to “add” methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type.
That means we can extend methods from any type, even types where we don’t have access to the source code.
Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type.
We build extension methods by declaring it as a static method, but there is a little tweak makes it compile into a method that can be called from an instance.
Continue reading →