[Mono-list] Problem extending collection with generics

Dan Smithers dsmithers at talktalk.net
Wed Jan 9 09:26:28 EST 2008

Thanks Robert, that seems to sort it out.

Also, when do I need to use the override keyword? It seems a little
redundant as it can only be used for methods that have been declared
virtual in the base class.



Robert Jordan wrote:
> 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
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

More information about the Mono-list mailing list