using System; namespace Martin.Baulig { public class X { public int A; } public class Y { public int B; } public struct SomeStruct { public int A; public R Data; public SomeStruct (int a, R data) { this.A = a; this.Data = data; } } public class Test where S : new () { public S Data; public Test () { this.Data = new S (); } public void Hello () { Console.WriteLine (Data); } } public class Foo where T : new () { public readonly T Data; public readonly Test Test; public Foo () { Data = new T (); Test = new Test (); Test.Data = Data; } public void Hello (U u) { Console.WriteLine (u); Console.WriteLine (Data); Console.WriteLine (Test); SomeStruct a = new SomeStruct (5, Data); Console.WriteLine (a); } } class GenericTest { static void Main () { Foo x = new Foo (); Foo y = new Foo (); Foo> test = new Foo> (); x.Data.A = 5; y.Data.B = 9; test.Data.Data = 512; x.Hello (y); y.Hello (x); test.Hello ("Hello World"); Console.WriteLine (test.Data.Data); } } }