The difference of typeof and GetType method
来源:互联网 发布:mmd口型数据 编辑:程序博客网 时间:2024/04/20 21:17
first,we will say the typeof is the type of the class,but the GetType is the class of instance
second,typeof is in the compile time,the GetType is in the runtime
and the GetType is a vitual method,so must care
code:
Animal animal = new Animal();
Dog dog = new Dog();
Animal ADog = new Dog();
Response.Write(animal.GetType() + "——animal.GetType() </br> ");
Response.Write(dog.GetType() + "——dog.GetType() </br> ");
Response.Write(ADog.GetType() + "——ADog.GetType() </br> ");
Response.Write(typeof(Animal) + "——typeof(Animal) </br> ");
Response.Write(typeof(Dog) + "——typeof(Dog) </br> ");
result:
无标题页KDia.testtypeof.Animal——animal.GetType()
KDia.testtypeof.Dog——dog.GetType()
KDia.testtypeof.Dog——ADog.GetType()
KDia.testtypeof.Animal——typeof(Animal)
KDia.testtypeof.Dog——typeof(Dog)
so the GetType() method is in the runtime,the typeof is in the compile time
- The difference of typeof and GetType method
- The Difference of Override and Overload
- the difference of retain and assign
- the difference of heap and stack
- the difference of real and fake fingerprint
- What's the difference and compatibility of CGLayer and CALayer?
- The use method of afxDump and TRACE
- The comparison of the toString() method and the valueOf(...) method of the String class
- typeof与Type.GetType()
- getType() 和Typeof()
- C#/GetType()与typeof
- The difference of Heap and Stack(转贴)
- The difference of overriding between C# and Java
- the difference between ClientID and ID of web control
- String and some of the difference between StringBuffer
- The difference of static, readonly and const in C#
- The difference of SE Detail UI between 2.4 and 4.0
- The difference of gets(),getch(),getchar() and getline()
- 40天里我剪掉了差不多7公斤
- 平台崩溃之operator new异常(十)-2010-5-21
- 明明白白我的心
- 15 个 JavaScript Web UI 库
- pure pure heart 歌词
- The difference of typeof and GetType method
- 汉字按字节进行计算,并进行分解,用于短信机发送
- DataSet多表关联实现本地数据复杂的查询
- 要去杭州了。。有点不舍
- 快速排序QuickSort.c
- 坚持每天至少一百行。练习数据结构线性表
- SQL日期转换函数
- 日期转换处理相关
- 指令名称 : chmod