Re: Hiding base class methods
- From: "DanielF" <DanielF@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 1 Jun 2005 08:35:12 -0700
OK, thanks - that does the trick!.
"Tim Wilson" wrote:
> If you compile the following code into an assembly, and then reference this
> assembly in a project, then when you create an instance of the "Derived"
> class, the method named "Method" will not show up in the editor through
> intellisense. AFAIK, this is the only way to accomplish hiding inherited
> members from an end-developer. Of course, if the end-developer specified
> that the "Method" should be called against an instance of the "Derived"
> class, although they will not get intellisense to complete the code, it will
> compile since the method does exist. This is the reason why the
> "NotSupportedException" is pitched.
>
> using System;
> using System.ComponentModel;
>
> namespace MyNamespace
> {
> public class Base : System.Object
> {
> public void Method()
> {
> // Do something.
> }
> }
>
> public class Derived : Base
> {
> [EditorBrowsableAttribute(EditorBrowsableState.Never)]
> public new void Method()
> {
> throw (new NotSupportedException("This method is not supported."));
> }
> }
> }
>
> --
> Tim Wilson
> ..Net Compact Framework MVP
>
> "DanielF" <DanielF@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:78234655-2BEF-4A35-9881-CC21C1DAA541@xxxxxxxxxxxxxxxx
> > I would like to find a way to completely hide selected methods of a base
> > class when inheriting from that base class. I know how to override a
> method
> > and replace a base class method using the "new" modifier on the method,
> but
> > then the method of the derived class shows up. I would like to be able to
> > completely hide a method so that it doesn't show up at all in an
> application
> > that instantiates the derived class. Any help would be appreciated.
>
>
>
.
- Prev by Date: show windows in pocket pc
- Next by Date: Re: what is wrong with help system?
- Previous by thread: show windows in pocket pc
- Next by thread: VPN to sqlserver?
- Index(es):
Relevant Pages
|