예제 #1
0
 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();
     }
 }
예제 #2
0
        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
        }
예제 #3
0
 public static void EstensionMethodForTestClass(this Test testClassInstance)
 {
     Console.WriteLine("EstensionMethodForTestClass(this Test testClassInstance)");
     testClassInstance.TestMethod();
     Console.WriteLine(testClassInstance.Date);
 }