typeofによる 型(System.Type)の取得

2009/10/15 16:58更新
TAGS: typeof | getType || C#

クラスのSystem.Type オブジェクト取得方法について。

typeofによるSystem.Typeの取得


例1:
System.Type type = typeof(int);


例2:
System.Type type = typeof(MyClassName);


GetType()メソッドによるSystem.Typeの取得


例3:
int i = 0;
System.Type type = i.GetType();


例4:
MyClassName myClass = new MyClassName();
System.Type type = myClass.GetType();


参考資料


typeof (C#) 「MSDN」

著者について
Syboos.jp編集長システム設計や開発、保守運営などを行ってます。オープンソース技術に興味があります。

Sponsored Link


コメント