To interface or not to interface

Kagamin spam at here.lot
Thu May 27 00:09:43 PDT 2010

> ICollection<A> acoll;
> ICollection<B> bcoll;
> A[] cat;
> ICollection<A>.CopyTo(A[],int)
> ICollection<B>.CopyTo(B[],int) - note the signature, the destination array can't be an array of supertype. There's no chance to throw an exception because the code doesn't pass type check at compile time.

To ease understanding:

ICollection<Animal> acoll;
ICollection<Cat> ccoll;
Animal[] animals;

More information about the Digitalmars-d mailing list