Difference between Foo<T> where T : BaseObject and Foo<BaseObject>

c#, generics

Solution

No, it is not the same.

With:

Foo<T> where T : BaseObject

`T` can be any `BaseObject` type and its inheritors.

With:

Foo<BaseObject>

`T` must be `BaseObject` exactly (assuming no variance modifiers were declared in `Foo` for the generic type parameter).

Problem

What is the difference between ``` Foo<T> where T : BaseObject ``` and ``` Foo<BaseObject> ``` Isn't this statement the same?

Original source

Related problems