Re: Hiding base class methods



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.
>
>
>
.



Relevant Pages

  • Re: question on multidimensional array
    ... > other compile errors in addition to that.. ... > voor het frame ... > public class Speelveld ...
    (comp.lang.java.help)
  • Re: [OT] Win32 JNI Console Class [was: Re: Clear the Screen]
    ... I know from some experience with Linux, the native code you are making into ... So when you are making your shared library you need to compile it with the ... If the library is compiled without being position independent then when you ... >> public class Console ...
    (comp.lang.java)
  • Re: Feature request for C# Generic inheritence
    ... I thought that for generic inheritance, the compiler will create an explicit type at compile time. ... Same way anonymous method works. ... public class GenericDecorator: T ... extender.Data (give the same ability as EventArgsbut more generic which can leverage other types that do not support generics. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: compile javac help needed for beginner. apparently it doesnot understand the word extends?????
    ... > class Customer extends Person { ... > I compile Person.java ... public class Persion { ...
    (comp.lang.java.programmer)
  • RE: Question on "Shadowing"
    ... objects - the shadowing members are duplicates created in the derived class. ... > Public Class StreamsDataTable ... > Public ReadOnly Property Streams As StreamsDataTable ...
    (microsoft.public.dotnet.languages.vb)