int[] arr = new int[5];
Console.WriteLine(arr.Count.ToString());//Compiler Error
Console.WriteLine(((ICollection)arr).Count.ToString());//works p
While System.Array
implement the ICollection
interface it doesn't directly expose the Count
property. You can see the explicit implementation of ICollection.Count
in the MSDN documentation here.
The same applies to IList.Item
.
Take look at this Blog entry for more details on explicit and implicit interface implementation: Implicit and Explicit Interface Implementations