特定のプロパティやメソッドをインテリセンス上で非表示にする. (EditorBrowsable, EditorBrowsableState.Never, Intellisense) - いろいろ備忘録日記
http://d.hatena.ne.jp/gsf_zero1/20080418/p1
ここには、たとえば、
http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=43996&forum=7
で紹介されている EditorBrowsable の解説がある。
これを使うと、
using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public struct Hoge { private int x; public static Hoge Foo = new Hoge(0); public Hoge(int argX) { x = argX; } [EditorBrowsable(EditorBrowsableState.Always)] public static Hoge Bar { get { return Hoge.Foo; } } } }
と書いておくと、Visual Studio 上で、
Hoge hoge = Hoge.
と打ち込んだ時に、インテリセンスの選択肢に Bar も表示できるようになる。(Foo はデフォルトの状態ですでに表示されている。)
なお、
using System.ComponentModel;
が必要なことに注意する。