using System; using System.Collections.Generic; public struct GenStruct { public int inc (int i) { return i + 1; } public T[] newArr () { return new T [3]; } } public class Bla { public bool work (IList l) { foreach (string s in l) { if (s.Length != 1) return false; } return true; } } public interface GenInterface { T[] newArr (); } public struct GenIntStruct : GenInterface { public T[] newArr () { return new T [3]; } } public interface GenFactory { GenInterface makeInterface (); } public class Gen : GenFactory { public GenInterface makeInterface () { return new GenIntStruct (); } } public class NonGen : GenFactory { public GenInterface makeInterface () { return new GenIntStruct (); } } public class main { public static bool testInterface (GenFactory gf) { GenInterface gi = gf.makeInterface (); if (gi.newArr ().GetType () != typeof (string [])) return false; return true; } public static int Main () { GenStruct gso = new GenStruct (); GenStruct gss = new GenStruct (); if (gso.inc (1) != 2) return 1; if (gss.inc (2) != 3) return 1; if (gso.newArr ().GetType () != typeof (object [])) return 1; if (gss.newArr ().GetType () != typeof (string [])) return 1; Gen g = new Gen (); testInterface (g); NonGen ng = new NonGen (); testInterface (ng); Bla bla = new Bla (); string [] arr = { "a", "b", "c" }; if (!bla.work (arr)) return 1; return 0; } }