[Mono-list] Help John's poor tired brain.

John Barnette jbarn@httcb.net
Sun, 15 Jul 2001 01:14:10 -0600


> The problem seems to be that Hashtable GetEnumerator function returns an
> IDictionaryEnumerator, which is derived from IEnumerator, and should
> therefore be okay.  Unfortunately the compiler doesn't catch this.  My
> suggestion for now would just be to set it aside by returning an
> IEnumerator.  Hopefully our compiler won't have this problem :)


'Course, the problem is that switching to just

		public virtual IEnumerator GetEnumerator() {
			return null;
		}

yields (of course) another error about an incomplete implementation of
IDictionary: "error CS0536: 'System.Collections.JBHashtable' does not
implement interface member 'System.Collections.IDictionary.GetEnumerator()'.
'System.Collections.JBHashtable.GetEnumerator()' is either static, not
public, or has the wrong return type."


~ j.

> On 14 Jul 2001 23:57:01 -0700, Jason Diamond wrote:
> > Try using an explicit interface implementation:
> >
> > public virtual IEnumerator IEnumerable.GetEnumerator() {
> > 	return null;
> > }
> >
> > Jason.
> >
> > > -----Original Message-----
> > > From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com]On
> > > Behalf Of John Barnette
> > > Sent: Saturday, July 14, 2001 11:42 PM
> > > To: mono
> > > Subject: [Mono-list] Help John's poor tired brain.
> > >
> > >
> > > Okay, so Hashtable implements IEnumerable and IDictionary,
> both of which
> > > define a GetEnumerator() method.  Specifically:
> > >
> > > IEnumerable:
> > > 	IEnumerator GetEnumerator();
> > >
> > > IDictionary:
> > > 	IDictionaryEnumerator GetEnumerator();
> > >
> > > IDictionary inherits from IEnumerable:
> > > 	public interface IDictionary : ICollection, IEnumerable
> > >
> > >
> > > Attempting to compile my Hashtable with this stubbed implementation of
> > > GetEnumerator():
> > >
> > > 		public virtual IDictionaryEnumerator GetEnumerator() {
> > > 			return null;
> > > 		}
> > >
> > > ...yields a pleasant compiler error:
> > >
> > > "error CS0536: 'System.Collections.JBHashtable' does not
> > > implement interface
> > > member 'System.Collections.IEnumerable.GetEnumerator()'.
> > > 'System.Collections.JBHashtable.GetEnumerator()' is either static, not
> > > public, or has the wrong return type."
> > >
> > > Help!  I'm tired, I just wrote the threadsafe wrapper, and I
> want to go to
> > > sleep. ;-)
> > >
> > >
> > > ~ j.
> > >
> > >
> > > _______________________________________________
> > > Mono-list maillist  -  Mono-list@ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-list
> > >
> >
> >
> > _______________________________________________
> > Mono-list maillist  -  Mono-list@ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>