How to Hide inherited Object members from intellisense?

W

wackyphill

...Such as ToString(), Equals(), etc.

[EditorBrowsable(EditorBrowsableState.Never)]
public override String ToString() { return base.ToString(); }

The above doesn't work.

Any ideas? And before you ask, Yes I do have a sane reason for wanting
to do this.
 
C

Chris Dunaway

[EditorBrowsable(EditorBrowsableState.Never)]
public override String ToString() { return base.ToString(); }

The above doesn't work.

Have you tried just the Browsable attribute?

[Browsable(false)]
public int MyProperty {
get {
// Insert code here.
return 0;
}
set {
// Insert code here.
}
}
 
C

Chris Dunaway

So it does! My mistake.

I just tried the EditorBrowsable attribute on a property and also on a
method and it worked correctly. I then tried it on an overridden
ToString method and it *did not* work on that method.

Next I created a simple class with one overridable method and a derived
class that overrides the method with an additional method that was not
part of the base class. It seems that if the overridden method is
hidden using the EditorBrowsable attribute, then the base class method
is exposed. This was coded in VB.Net. I then repeated the test in C#
but the EditorBrowsable attribute seemed to have no effect either way.


It seems very strange.
 
W

wackyphill

Yeah, I don't understand it really. I'm not really interested in
overriding just hiding the methods from the intellisense window.

I guess what I'd really like to do is apply the EditorBrowsable
attribute to an inherited method like ToString(); Just don't know how.

I wish something like this would work to do it:

class MyClass : Object
{
MyClass() {}

[EditorBrowsable(EditorBrowsableState.Never)]
public String ToString();
}

Of course it's not valid but that's my intent. Thanks for the
investigative effort Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top