Why does C# not allow generic properties?

后端 未结 5 1647
野性不改
野性不改 2020-12-03 07:03

I was wondering why I can not have generic property in non-generic class the way I can have generic methods. I.e.:

public interface TestClass
{
   IEnumerabl         


        
5条回答
  •  感动是毒
    2020-12-03 07:24

    My guess is that it has some nasty corner cases that make the grammar ambiguous. Off-hand, this seems like it might be tricky:

    foo.Bar=3;
    

    Should that be parsed as:

    foo.Bar = 3;
    

    Or:

    foo.Bar < Baz >= 3;
    

提交回复
热议问题