Why it is not possible to define generic indexers in .NET?

后端 未结 7 785
灰色年华
灰色年华 2020-12-05 12:31

Why can\'t you create a generic indexer in .NET?

the following code throws a compiler error:

   public T this[string key]
   {
      get { /         


        
相关标签:
7条回答
  • 2020-12-05 13:29

    Properties can't be generic in C#2.0/3.0 so therefore you can't have a generic indexer.

    0 讨论(0)
提交回复
热议问题