The System.Array
class implements ICollection
interface.
This interface has a public property called Count
which gives the number of elements in the array.
Suppose I declare an Array and access its properties
Array numbers = Array.CreateInstance(typeof(int), 10);
Console.WriteLine(numbers.Count);
You would expect to see 10 on the screen.
But, I am not able to see Count
property after putting a period after numbers. There is however, a property called Length
. Why is it so?
Update:
This is because of Explicit Interface Implementation. Since there is another question similar to mine, I decided to re-word it.
Why was the design decision taken to explicitly implement this particular property? There is another property with the same functionality Length
. So why go through the trouble of providing the explicitly implemented Count
?