Search code examples
c#arraysicollection

Does System.Array Really Implement ICollection?


According to MSDN docs, System.Array implements ICollection, yet System.Array does not provide a Count property (of course you can always use the LINQ Count() extension method, but there is no property with this name). How can this be? Isn't Count required?


Solution

  • It's explicitly implemented like so:

    int ICollection.Count
    {
        get
        {
            return Length;
        }
    }
    

    You can read more about explicit interface implementation on MSDN.