Why doesn't C# support variant generic classes? [duplicate]
问题 This question already has answers here : .NET 4.0 Covariance (3 answers) Closed 4 years ago . Take this small LINQPad example: void Main() { Foo<object> foo = new Foo<string>(); Console.WriteLine(foo.Get()); } class Foo<out T> { public T Get() { return default(T); } } It fails to compile with this error: Invalid variance modifier. Only interface and delegate type parameters can be specified as variant. I don't see any logical problem with the code. Everything can be statically verified. Why