为什么IReadOnlyCollection具有ElementAt但没有IndexOf?

7 浏览
0 Comments

为什么IReadOnlyCollection具有ElementAt但没有IndexOf?

我正在使用一个对象的

现在我有点惊讶,因为我可以使用linq扩展方法ElementAt()。但我无法访问IndexOf()

对我来说,这看起来有点不合逻辑:我可以得到给定位置的元素,但我无法得到该元素的位置。

是否有具体的原因?

我已经阅读过-> How to get the index of an element in an IEnumerable?,但我对答案不完全满意。

0