Creation and Usage of csharp Dotnet Extension Method with Example

Extension Methods in C#

Extension Methods were introduced in c# 3.0. These methods are helpful in adding methods to the types which already existed i.e without creating a derived type via inheritance, methods can be added to existing type. In short functionality of existing type is extended.

Creation and Usage of Extension method

Extension method can be defined as static method within static class where first parameter in this method is used with “this” modifier and type of this parameter is of the type that is extended.

Program demonstrating usage of extention methods

First create a blank solution named “ExtmethodExample” in visual studio 2015. Create a project Class Library named as “Extmethod”.

Continue your Reading here>> Usage of csharp Dotnet Extension Method with Example