For a very long time I was curious about the following:
int[] array = new int[1];
int iArrayLength = array.Length; //1
Since arrays implement the IList interface, the following is allowed:
int iArrayCount = ((IList<int>)array).Count; //still 1
BUT:
int iArrayCount = array.Count; //Compile error. WHY?
int iArrayLength = array.Length; //This is what we learned at school!
The question:
How can an array implement IList<T>
(especially the int Count { get; }
property from IList<T>
) without allowing it to be used on the base class?