System.Array真的实现了ICollection吗?

Pau*_*ter 7 c# arrays icollection

根据MSDN文档,System.Array实现ICollection,但System.Array不提供Count属性(当然,您总是可以使用LINQ Count()扩展方法,但是没有具有此名称的属性).怎么会这样?是不是需要数量?

vcs*_*nes 8

明确地实现如下:

int ICollection.Count
{
    get
    {
        return Length;
    }
}
Run Code Online (Sandbox Code Playgroud)

您可以在MSDN上阅读有关显式接口实现的更多信息.

  • 该死的你今天这么快! (3认同)
  • @JustinNiessner当我在发布答案后上升1秒后,我总是假设"我打赌我只是生气地写了相同的答案" - 因为它始终发生在我身上:-P. (2认同)