typeof和GetType区别

两者都是返回当前的类型

1、typeof(X);    其中的 X 是类型。
2、X.GetType();    其中的 X 是变量或类型的实例。

例如:有变量 string str=new string();
   typeof表示:  typeof(string)
   GetType表示:  str.GetType() 

posted @ 2013-05-09 09:06  武沛齐  阅读(277)  评论(0编辑  收藏  举报