Hi Bruce,
Actually, you can hide any member from the IDE and IntelliSense by applying
EditorBrowsableAttribute to its override or "new" implementation:
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj)
{
return base.Equals(obj);
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static new bool ReferenceEquals(object objA, object objB)
{
return object.ReferenceEquals(objA, objB);
}
The IDE ignores EditorBrowsableAttribute from within the same project so it
only has an affect on referenced projects. Also, this doesn't prevent
consumption of the attributed members, only their presence in IntelliSense.
That means that you should still provide an implementation (as I've done
above) so that callers can use the methods if they choose. i.e., Even with
the Equals method attributed as above callers can still write:
bool equals = yourObjInst.Equals(anotherObj);
although they won't get any editor support for calling the method.
To be perfectly honest though, I can't see why you would want to hide either
of these methods in the first place, so I'd recommend that you don't do this
unless you have a really good reason to.
This works in C# and VB.NET, but I don't know about managed C++.
--
Dave Sexton
http://davesexton.com/blog
"Bruce" <Br***@nospam.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
Joanna Carter [TeamB] wrote:
>"Bruce" <Br***@nospam.coma écrit dans le message de news:
OO**************@TK2MSFTNGP06.phx.gbl...
| I have a class in a class assembly, that just has a bunch of static
| methods. How can I hide the Equals and ReferenceEquals properties
| from my end user programmer?
Anything that is marked public cannot be hidden from other users of that
class. The only way to hide something is to mark it as private, protected
or internal, depending on the degreee of hiding desired.
Joanna
Is there any way to derive my class from something other than Object then?
How does Microsoft do it with Microsoft.VisualBasic.ChDir() for example?
I take it VisualBasic is a namespace? If so, how do they export Chdir,
doesn't it have to be a part of a class?
--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com