[英]Type.BaseType in Portable Class Library
Write the following code: 编写以下代码:
public class Class1 { public static Type GetBaseType(Type type) { return type.BaseType; } }
Observe that you cannot compile: "'System.Type' does not contain a definition for 'BaseType' and no extension method 'BaseType' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)" 观察到您无法编译:“'System.Type'不包含'BaseType'的定义,并且找不到扩展方法'BaseType'接受类型为'System.Type'的第一个参数(您是否缺少using指令或组装参考?)”
Strange since the MSDN documentation clearly states this property should be present: http://msdn.microsoft.com/en-us/library/system.type.basetype(v=vs.110).aspx 奇怪的是,由于MSDN文档明确指出应存在此属性: http : //msdn.microsoft.com/zh-cn/library/system.type.basetype(v=vs.110).aspx
It is not available in WinRT apps. 在WinRT应用程序中不可用。 Properties and methods supported in WinRT have this mentioned explicitly (look at the store icon) - http://msdn.microsoft.com/en-us/library/system.type(v=vs.110).aspx WinRT支持的属性和方法对此进行了明确提及(请参见商店图标) -http://msdn.microsoft.com/zh-cn/library/system.type (v=vs.110) .aspx
This answer provides a workaround for WinRT - What is the equivalent to Type.BaseType in WinRT? 此答案提供了WinRT的解决方法-WinRT中的Type.BaseType等效于什么?
Type.GetTypeInfo().BaseType
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.