Q:

public T GetMyClass() where T : MyClass, new() { /* is this pointless? */ }

are the two methods in the class "Confused" below the same?
class MyClass
{
    public override string ToString()
    {
        return "I am confused now";
    }
}

class Confused
{    
    public MyClass GetMyClass()
    {
        return new MyClass();
    }

    public T GetMyClass<T>() where T : MyClass, new()
    {
        return System.Activator.CreateInstance<T>();
    }
}

class Program
{
    static void Main()
    {
        Confused c = new Confused();
        System.Console.WriteLine(c.GetMyClass());
        System.Console.WriteLine(c.GetMyClass<MyClass>());
    }
}

They produce different IL, but is there any reason to write the generic version other than the 'straight up' version other than to confuse the heck out of collegues :)

A:

If you write the generic version, you can instantiate and return derived classes:
where T : MyClass
Also, with the generic version you don't need the activation code:
return new T();
This is because you have specified:
where T : new()
The generic constraint enforcing a public parameterless constructor.

A:

Sure there's a difference. Let's say you have a second class deriving from MyClass:
class MyClass2 : MyClass { }

Then you can do
MyClass2 myClass2 = confused.GetMyClass<MyClass2>();

You can't do that with the other function.

