C# typeof 与GetType()的区别
C#中Type类的介绍:https://msdn.microsoft.com/zh-cn/library/system.type(VS.80).aspx
C#中任何对象都具有GetType()方法,它的作用和typeof()相同,返回Type类型的当前对象的类型。typeof(x)中的x,必须是具体的类名、类型名称等,不可以是变量名称;GetType()是基类System.Object的方法,因此只有建立一个实例之后才能够被调用
两者区别:
1、Typeof是运算符而是方法
2、GetType()是基类System.Object的方法,因此只有建立一个实例之后才能够被调用(初始化以后)
3、Typeof的参数只能是int,string,String,自定义类型,且不能是实例
4、GetType()和typeof都返回System.Type的引用.
5、TypeOf():得到一个Class的Type
6、 GetType():得到一个Class的实例的Type
C# typeof 与GetType()的区别的更多相关文章
- typeof和GetType的区别
http://stackoverflow.com/questions/4537945/what-is-the-difference-of-getting-type-by-using-gettype-a ...
- typeof与GetType
typeof: The typeof operator is used to obtain the System.Type object for a type. 运算符,获得某一类型的 System. ...
- 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 是特殊类型的引用类型. 使用方法: ...
- call()与apply()区别typeof和instanceof的区别
摘自 http://www.cnblogs.com/qzsonline/archive/2013/03/05/2944367.html 一.方法的定义 call方法: 语法:call(thisObj, ...
- typeof()和instanceof()用法区别
typeof()和instanceof()用法区别: 两者都是用来判断数据类型的 typeof()是能用来判断是不是属于五大类型Boolean,Number,String,Null,Undefined ...
- typeof和instanceof的区别
typeof和instanceof的区别: typeof typeof 是一个一元运算,放在一个运算数之前,运算数可以是任意类型.它返回值是一个字符串,该字符串说明运算数的类型.typeof 一般只能 ...
- 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 ...
随机推荐
- 结合Ajax做地区内容切换!(城市切换)
实现原理:点击,进行异步保存Cookie , 根据保存的Cookie来切换城市内容: 简单HTML示例: <!doctype html> <html> <head> ...
- 170620、springboot编程之页面版Hello World
书接上回,把Hello World 在页面上显示! 1.在pom文件中加入web支持 <dependency> <groupId>org.springframework.boo ...
- ASP.NET网站性能优化
如果你是一个做过ASP网站,又做过ASP.NET网站的程序员,你可能会发现,如果按正常的思路开发ASP.NET网站,ASP.NET网站的速度会比ASP网站慢很多,为什么强大的网站语言会比弱得慢的,原因 ...
- Code Forces 18D Seller Bob(简单DP)
D. Seller Bob time limit per test 2 seconds memory limit per test 128 megabytes input standard input ...
- proxy ubuntu proxy--http://jingyan.baidu.com/article/8cdccae9913470315513cd70.html
apt-get 设置代理 proxy 方法 方法一 :这是一种临时的手段,如果你仅仅是暂时需要通过http代理使用apt-get,你可以使用这种方法. 在使用 apt-get 之前,在终端中输入以下 ...
- Linux环境下proc的配置c/c++操作数据库简单示例
在虚拟机上装了oracle11g数据库,原本想利用c/c++学习操作数据库.结果感觉摊上了一个大坑.从安装好oracle数据库到配置好proc的编译选项整整花了二天.但让我意识到自己自己几点薄弱:1. ...
- EasyUI Draggable 可拖动
通过 $.fn.draggable.defaults 重写默认的 defaults. 用法 通过标记创建可拖动(draggable)元素. <div id="dd" clas ...
- ffmpeg应用笔记
官网 http://ffmpeg.org/ 应用手册 http://ffmpeg.org/documentation.html 雷霄骅专栏 https://blog.csdn.net/leixiaoh ...
- WebDriver API 实例详解(四)
三十一.使用页面的文字内容识别和处理新弹出的浏览器窗口 被测试网页的HTML源码: <html> <head> <meta charset="UTF-8&quo ...
- [LeetCode] 82. Remove Duplicates from Sorted List II_Medium tag: Linked List
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinctnumbe ...