typeof与GetType
typeof: The typeof operator is used to obtain the System.Type object for a type.
运算符,获得某一类型的 System.Type 对象。
Type t = typeof(int);
GetType: Gets the Type of the current instance.
方法,获取当前实例的类型。
int i = 10;
Console.WriteLine(i.GetType());
区别:
- Typeof()是运算符而GetType是方法
- GetType()是基类System.Object的方法,因此只有建立一个实例之后才能够被调用(初始化以后)
- Typeof()的参数只能是int,string,String,自定义类型,且不能是实例
- GetType() 和typeof()都返回System.Type的引用。
TypeOf() 和GetType()的区别:
(1)TypeOf():得到一个Class的Type
(2)GetType():得到一个Class的实例的Type
override 一个方法的前担是这个方法在父类中:abstract or virtual, override
typeof与GetType的更多相关文章
- typeof与GetType区别及反射的见解
http://www.cnblogs.com/knowledgesea/archive/2013/03/02/2935920.html http://www.cnblogs.com/Jax/archi ...
- 值类型与引用类型(特殊的string) Typeof和GetType() 静态和非静态使用 参数传递 相关知识
学习大神博客链接: http://www.cnblogs.com/zhili/category/421637.html 一 值类型与引用类型 需要注意的string 是特殊类型的引用类型. 使用方法: ...
- typeof和GetType的区别
http://stackoverflow.com/questions/4537945/what-is-the-difference-of-getting-type-by-using-gettype-a ...
- C# typeof() 和 GetType()区别
1.typeof(x)中的x,必须是具体的类名.类型名称等,不可以是变量名称. 2.GetType()方法继承自Object,所以C#中任何对象都具有GetType()方法,它的作用和typeof() ...
- c# typeof 与 GetType 作用与区别
官方解释: Used to obtain the "System.Type" object for a type. A 'typeof' expression takes the ...
- typeof() 和 GetType()区是什么
1.typeof(x)中的x,必须是具体的类名.类型名称等,不可以是变量名称. 2.GetType()方法继承自Object,所以C#中任何对象都具有GetType()方法,它的作用和typeof() ...
- default(T) 和 typeof 和 GetType()
一.default(T) 在泛型编成中如果不限制T类型参数是值类型或引用类型的话 你程序内部可能会出现错误,因为值类型不允许NULL.所以default用来获取一个类型的默认值,对于值类型得到new ...
- C# typeof 与GetType()的区别
C#中Type类的介绍:https://msdn.microsoft.com/zh-cn/library/system.type(VS.80).aspx C#中任何对象都具有GetType()方法,它 ...
- C# typeof() 和 GetType()区是什么
1.typeof(x)中的x,必须是具体的类名.类型名称等,不可以是变量名称. 2.GetType()方法继承自Object,所以C#中任何对象都具有GetType()方法,它的作用和typeof() ...
随机推荐
- Hello.class所在路径下, 输入命令:java Hello.class,会出现什么结果,为什么?
所在路径下, 输入命令:java Hello.class: 因为DOS没有规定路径,所有么有在默认路径下找到Hello.class文件,导致提示 错误: 找不到或无法加载主类 Hello.class.
- Android系统分区理解及分区目录细解
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- UIButton的titleEdgeInsets和imageEdgeInsets属性
转:http://www.cnblogs.com/huichun/p/3419596.html uiButton控件上自带了一个uiLabel类型的子控件和一个uiImageView类型的子控件,如果 ...
- HDU 1711 Number Sequence (KMP)
白书说这个是MP,没有对f 数组优化过,所以说KMP有点不准确 #include <stdio.h> int a,b; int T[1000010],P[10010];//从0开始存 in ...
- redolog文件头简单探究
先切换: SQL> select group#,status from v$log; GROUP# STATUS---------- ---------------- 1 INA ...
- java综合
java环境变量配置:http://jingyan.baidu.com/article/f96699bb8b38e0894e3c1bef.html 1.导入项目 当下载了包含Eclipse 项目的源代 ...
- find the peak value
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ ...
- <a>标签href属性与onclick事件
a标签主要用来实现页面跳转,可以通过href属性实现,也可以在onclick事件里实现. <a onclick="window.location.href='www.cnblogs.c ...
- C# 匿名委托、匿名方法、匿名对象、Lambda表达式
一.匿名类型可通过使用 new 运算符和对象初始值创建匿名类型.示例:var v = new { Name = "Micro", Message = "Hello&quo ...
- Codeforces 346C Number Transformation II 构造
题目链接:点击打开链接 = = 990+ms卡过 #include<stdio.h> #include<iostream> #include<string.h> # ...