Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 677
Paul Keister Avatar asked May 01 '14 20:05

Paul Keister


People also ask

What interfaces does Array implement C#?

What are the interfaces implemented by Array class in C#? System. Array implements interfaces, like ICloneable, IList, ICollection, and IEnumerable, etc. The ICloneable interface creates a copy of the existing object i.e a clone.

What is the maximum size of an Array in c#?

The array size is limited to a total of 4 billion elements, and to a maximum index of 0X7FEFFFFF in any given dimension (0X7FFFFFC7 for byte arrays and arrays of single-byte structures). . NET Framework only: By default, the maximum size of an Array is 2 gigabytes (GB).


1 Answers

It's explicitly implemented like so:

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

You can read more about explicit interface implementation on MSDN.

like image 148
vcsjones Avatar answered Sep 25 '22 13:09

vcsjones