[Mono-list] Problem extending collection with generics

Robert Jordan robertj at gmx.net
Wed Jan 9 06:54:36 EST 2008


Dan Smithers wrote:
> Hi,
> I have a small and irritating problem.
> I want to write a collection class derived from
> System.Collections.Generic.ICollection that contains a mathematical set.
> I have found it difficult to get it to compile because of the
> GetEnumerator methods.
> 
> I need to override both
> System.Collections.IEnumarable.GetEnumerator and
> System.Collections.Generic.IEnumerator<T>.GetEnumerator.
> 
> If I only have one defined then gmcs complains that the other is not
> defined.
> If I have both defined then gmcs complains that I have a nome conflict.
> 
> Can I get round this by explicitly specifying the derivation of the
> function. Is there any way to make it less verbose?

This ambiguity is usually solved with an explicit interface
implementation:

IEnumerator IEnumerable.GetEnumerator ()
{
	...
}

Robert



More information about the Mono-list mailing list