Ejemplo n.º 1
0
        public static GenericStruct <T> ReturnStruct(T y)
        {
            var res = new GenericStruct <T>();

            res.a = y;
            return(res);
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            GenericStruct <int>[] arr = new GenericStruct <int> [3];
            arr[0] = GenericStruct <int> .ReturnStruct(3);

            DerivedGenericClass <string, string> gc = new DerivedGenericClass <string, string>();
            string c = gc.func("oops");

            Console.WriteLine(c);
            gc.genericMethod("hello", arr[0].genericMethod2(3) ?? 0);
            GenericInterface <string> s = gc;

            s.genericMethod("goodbye", c);
            GenericClass <object> .myMethod(42);

            IVariance <string, int> q = null;

            q.func("nope");

            foreach (var v in arr)
            {
                v.genericMethod(64, "nope");
            }
        }