int[] arr = new int[5];
Console.WriteLine(arr.Count.ToString());//Compiler Error
Console.WriteLine(((ICollection)arr).Count.ToString());//works p
Arrays have .Length, not .Count.
But this is available (as an explicit interface implementation) on ICollection etc.
Essentially, the same as:
interface IFoo
{
int Foo { get; }
}
class Bar : IFoo
{
public int Value { get { return 12; } }
int IFoo.Foo { get { return Value; } } // explicit interface implementation
}
Bar
doesn't have public a Foo
property - but it is available if you cast to IFoo
:
Bar bar = new Bar();
Console.WriteLine(bar.Value); // but no Foo
IFoo foo = bar;
Console.WriteLine(foo.Foo); // but no Value