Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<>

后端 未结 7 1117
长情又很酷
长情又很酷 2020-12-14 05:41

Is there any specific reason why indexing is not allowed in IEnumerable.

I found a workaround for the problem I had, but just curious to know why it does not allow i

相关标签:
7条回答
  • 2020-12-14 06:11

    you can use indexing if your enumerable type is string like below

    ((string[])MyEnumerableStringList)[0]
    
    0 讨论(0)
提交回复
热议问题