[Mono-list] How to make a derived method "non-public"
Nick Drochak
ndrochak@gol.com
Mon, 6 Aug 2001 23:27:32 +0900
Fergus,
Thanks for that tip. It helped me find this C# feature in the language
spec. For anyone who's interested, especially C# newbies like me, class
members defined this way are called "explicit interface members". See the
C# Language Specification.doc, section 1.9, Interfaces.
Newbie note: You may have to look closely at the example below. At first, I
didn't see the qualifier "IHashCodeProvider." in front of the method name.
That turns out to be the whole point! :).
HTH,
Nick
-----Original Message-----
From: Fergus Henderson [mailto:fjh@cs.mu.oz.au]
Sent: Sunday, August 05, 2001 1:44 PM
To: Nick Drochak
Cc: mono-list@ximian.com
Subject: Re: [Mono-list] How to make a derived method "non-public"
On 05-Aug-2001, Nick Drochak <ndrochak@gol.com> wrote:
> I am working on System.Collections.CollectionBase. I noticed from the MS
> documentation (on MSDN [1]) that they show Clear() and RemoveAt() as
public
> members of the class. However, the other members from IList [2] are not.
>
> I don't know if my question is about C# or the docs, but is it
syntactically
> (is that a word?) possible to make some of IList members non-public in my
> class that inherits from it?
Yes, it is. You just define methods named "IList.Foo", "IList.Bar", etc.
Here's an example (using IHashCodeProvider):
using System.Collections;
public class Foo : IHashCodeProvider {
int IHashCodeProvider.GetHashCode(object obj) {
return 42;
}
}
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.