C#中他ypeof和GeType是干什么的?

来源:百度知道 编辑:UC知道 时间:2024/06/17 03:41:05
C#中他ypeof和GeType是干什么的?麻烦详细点,通俗点,谢谢
详细点》。。。。。。。

typeof 与 GetType 都可以算是获取一种类型的Type.
返回的对象是Type型.
Type t = typeof(string);
string s = "";
Type t1 = s.GetType();
上面2个就是返回一个 string 型的 Type.

比如 DataColume 第2个参数 指定这一列的数据类型.
通常就需要用到这种方法.
DataColumn dc = new DataColumn("c1", typeof(string));

判断和获取某个对象的类型