program.cs
using System; namespace Extension { class DekhiKiObostha { public void Test1() { Console.WriteLine("Method-1"); } public void Test2() { Console.WriteLine("Method-2"); } public void KiObostha() { Console.WriteLine("Hello Vai Koi Jaben ?"); } } }
StaticClass.cs
using System; namespace Extension { static class StaticClass { public static void Test3(this DekhiKiObostha s,int i) { Console.WriteLine("Method-3 :"+i); } } static class DclassTest { public static void TestDekhi(this DekhiKiObostha zaDekhiKiObostha,int o) { Console.WriteLine("Dlclass Test eta ="+o); } } }
TestExtensionMethods.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Extension { class TestDekhi { static void Main() { DekhiKiObostha dd = new DekhiKiObostha(); dd.Test1(); dd.Test2(); dd.Test3(10); dd.KiObostha(); dd.TestDekhi(8); Console.ReadKey(); } } }
output:
Method-1 Method-2 Method-3 :10 Hello Vai Koi Jaben ? Dlclass Test eta =8