Exemplo n.º 1
0
        static public void Run()
        {
            IExtend      interfaceExtend = new SomeClass();
            ClassExtend  classExtend     = new ClassExtend();
            StructExtend structExtend    = new StructExtend(10);

            //You can use extension methods to extend class, interface, structs.
            //But all extensions you declare, must be declared in a non-generic, non-nested, static class.
            interfaceExtend.ExtensionMethod();
            classExtend.ExtensionMethod();
            structExtend.ExtensionMethod();
        }
Exemplo n.º 2
0
 //overloaded to extend a struct type
 static public void ExtensionMethod(this StructExtend exStruct)
 {
     Console.WriteLine("Method extended for struct.");
 }