An extension method is special types of static method of a static class, where the "this" keyword is used as a first parameter of this method. And Extension methods allow existing classes to be extended without inheritance or also allow to change the source code of existing class.
You can also use an extension method, in whole project by including the namespace of an extension method.
Here is the simple example where we demonstrate the example of an extension method-
ClassTest.dll
{
{
{
}
}
}
ExtensionMethod.dll
{
{
{
Console. WriteLine( "Hello!... E xtended method called");
}
}
{
static void Main(string[] args)
{
Class1 obj = new Class1();
obj.Display();
obj.NewMethod();
Console.ReadKey();
}
}
}