我想知道为什么我不能在非泛型类中拥有泛型属性,就像我可以使用泛型方法一样.即:
public interface TestClass
{
IEnumerable<T> GetAllBy<T>(); //this works
IEnumerable<T> All<T> { get; } //this does not work
}
Run Code Online (Sandbox Code Playgroud)
我读了@Jon Skeet的回答,但这只是一个声明,很可能是规范中的某个地方.
我的问题是为什么它实际上是这样的?这种限制是否避免了一些问题?