[Mono-list] Array should have a Count property?

Serge serge@wildwestsoftware.com
Thu, 22 Nov 2001 13:33:51 +0200


It's quite simple. It's not that ICollection is special but under CLR
inheritance from particular interface doesn't imply also inheriting the same
names for methods. See .override directive description in Partition II,
9.3.2

In other words, Count should be coded like this:
     int ICollection.Count {get {Length;}}
This ensures that the property will be available only after casting Array to
ICollection.
I'm not sure about the error thrown by testsuite, it could be due to the
Array itself or maybe because of
System.Runtime.CompilerServices.InitializeArray call.

Sergey


----- Original Message -----
From: "Miguel de Icaza" <miguel@ximian.com>
To: "Nick Drochak" <ndrochak@gol.com>; <mono-list@ximian.com>
Sent: Thursday, November 22, 2001 12:21 AM
Subject: Re: [Mono-list] Array should have a Count property?


> > My first baffling question is this: Why doesn't the MS version of Array
> > does have a Count property even though Array implements ICollection.
> > (Mono's version of Array does, BTW.)
>
> This is puzzling.  The documentation for ICollection.Count says (this
> wording is very strange):
>
> `When implemented by a class, gets the number....'
>
> Contrast this wording with the wording of other interface methods (all
> the ICollection wording is like this).
>
> I have no idea of why we get this behavior.
>
> Miguel.
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>