什么时候UnderlyingSystemType从当前类型的实例不同 [英] When does the UnderlyingSystemType differ from the current Type instance
问题描述
的System.Type
包含 UnderlyingSystemType
属性。 MSDN 状态的,即:
System.Type
contains a UnderlyingSystemType
property. Msdn states that it:
表示公共语言运行时提供的类型 再presents此类型。
Indicates the type provided by the common language runtime that represents this type.
在大多数情况下,这个属性只是返回当前的键入
实例。
In most cases, this property simply returns the current Type
instance.
我的问题是,在什么情况下做这个属性的没有的返回电流键入
实例本身。在这些情况下,将是什么样类型的电流键入
实例,并返回底层系统类型是什么?
My question is, in what circumstances does this property not return the current Type
instance itself. And in those cases, what sort of type will be the current Type
instance and the returned underlying system type be?
推荐答案
说实话,我从来没有看到自己做的,但我知道,它有可能创建自己的 RuntimeType
喜欢你的指定类型的定义。
To be honest I never did it by myself, but I know that it is possible to create your own RuntimeType
like definition of your specified type.
如果您发现该键入
类是抽象的,有很多抽象的承包商,客人的。什么情况是,的您的类型(无论是)会自动创建 RuntimeType
从派生类型
类并实现它为你的类型。
If you notice the Type
class is abstract and has a lot of abstract memebers. What happens is that your type (whatever is it) automatically creates RuntimeType
derived from Type
class and implements it for your type.
所以,如果orindary的财产 UnderlyingSystemType
RuntimeType
返回键入
财产的平等价值,万一被覆盖的实现,相反,(即是影响relfection行为,但我要重申,我个人从来没有这样做过),将返回用户定义类型的值。
So the property UnderlyingSystemType
in case of orindary RuntimeType
will return Type
property equal value, in case of overriden implementation, instead, (that is for influencing relfection behavior, but I repeat I personally never did this before), will return user-defined type value.
修改
实际上,在发表了由人的链接是一个很好的:
Actually the link provided by guys in comments is a good one:
这篇关于什么时候UnderlyingSystemType从当前类型的实例不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!