typeof和GetType区别

两者都是返回当前的类型

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

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

原文地址:https://www.cnblogs.com/wupeiqi/p/3068279.html