C#中的typeof()及gettype()

用于获取类型的 System.Type 对象。typeof 表达式采用以下形式:

System.Type type = typeof(int);

若要获取表达式的运行时类型,可以使用 .NET Framework 方法 GetType,如下所示:

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

猜你喜欢

转载自blog.csdn.net/bocksong/article/details/80914969