public static void EstensionMethodForTestClassWithParameter(this Test testClassInstance, int x) { Console.WriteLine("EstensionMethodForTestClassWithParameter(this Test testClassInstance, int x)"); for (int i = 0; i < x; i++) { Console.Write("{0}: ", i); testClassInstance.TestMethod(); } }
static void Main(string[] args) { Test testObject = new Test(); testObject.TestMethod(); //method from Test testObject.TestMethod2(); //method from Test testObject.EstensionMethodForTestClass(); //extension method from Extensions #region supprise //Extensions.EstensionMethodForTestClass(testObject); #endregion testObject.EstensionMethodForTestClassWithParameter(10); //extension method from Extensions int result = testObject.EstensionMethodForTestClassWithParameter("COMARCH JARACZA 74/76"); //extension method from Extensions }
public static void EstensionMethodForTestClass(this Test testClassInstance) { Console.WriteLine("EstensionMethodForTestClass(this Test testClassInstance)"); testClassInstance.TestMethod(); Console.WriteLine(testClassInstance.Date); }