In this case, it is completely useless ... But let you have a method:
// In Test1<T> public List<T> GetList() { }
vs
and let's say that you have
public class TestSubclass: TestMain { }
Now you can:
List<TestSubclass> list1 = new Test1<TestSubclass>().GetList();
vs
List<TestMain> list2 = new Test2().GetList();
See different return types? If this is useful or not, it depends on how you structure your program.
I will say that the more common case is to add a constraint of type new() generic type:
public class Test1<T> where T : TestMain, new()
Now in Test1 you could:
public T GetNew() { return new T(); }
This is a "trick" that Test2 cannot do, because it will always return a new TestMain()
source share