Hiding System.Object default methods from IntelliSense
Every object in Microsoft’s .Net common language runtime (CLR) implements the System.Object interface. This means that every object in .Net has the following methods; Equals(), HashCode(), GetType(), and ToString(). While this is extremely helpful when you want to override ToString() (for use with DataGridView) or Equals().
It becomes annoying when using Microsoft’s IntelliSense. Every class will always expose these methods to IntelliSense. Since everyone but the most novice of programmers knows these classes exist there is little sense for IntelliSense to expose them. They add unnecessary clutter.
Thankfully there is a way to turn them off using the System.ComponentModel.EditorBrowsableAttribute namespace, which controls what members are visible in IntelliSense.
While you can choose for each and every class I prefer to use a single interface and just have my classes inherit from that interface.
namespace BlorkSamples.IntelliSense { [EditorBrowsable(EditorBrowsableState.Never)] public interface IInvisibleSystemObjectMethods { [EditorBrowsable(EditorBrowsableState.Never)] bool Equals(); [EditorBrowsable(EditorBrowsableState.Never)] int GetHashCode(); [EditorBrowsable(EditorBrowsableState.Never)] Type GetType(); [EditorBrowsable(EditorBrowsableState.Never)] string ToString(); } }
This hides the System.Object methods from IntelliSense and whenever writing your own interfaces or classes just inherit from this interface to hide its common methods. Extremely handy with large and confusing APIs.