Using LINQ for an object that only has GetEnumerator()

后端 未结 3 1358
萌比男神i
萌比男神i 2021-02-06 22:33

Can you use LINQ in an object that exposes only Add(), Remove(), Count(), Item() and GetEnumerator() from System.Collections.IEnumerator?

3条回答
  •  一个人的身影
    2021-02-06 23:06

    No you can't. All LINQ methods are extensions methods for the IEnumerable interface.

    So you'll have to implement IEnumerable to use LINQ with your own collections.

提交回复
热议问题