[Mono-list] Problem extending collection with generics

Daniel Soto daniel.soto2k at gmail.com
Wed Jan 9 09:41:15 EST 2008


The override keyword indicates that the method overrides the virtual method
in the base class, but this is not obligation in virtual methods. This is
equivalent to Overridable and Overrides keywords in visual basic.net.

However, you must override the method if the method in the base class is
declared as abstract. This is equivalent to MustOverride keyword in visual
basic.net.

Best Regards.


2008/1/9, Dan Smithers <dsmithers at talktalk.net>:
>
> 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.
>
> thanks
>
> dan
>
> 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
> >
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080109/ecc227c9/attachment-0001.html 


More information about the Mono-list mailing list