Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将一些代码移植到 WinRT/Metro,但遇到了一个我不确定解决方法的问题。似乎 Type 缺少 IsPrimitive 和 IsSubclassOf(myClass) 等的访问功能。有人知道如何在 Windows 8 中获得此功能吗?
这些方法被重新定位;你需要添加一个using指令:
using
using System.Reflection;
然后使用someType.GetTypeInfo().IsSubclassOf(...)和someType.GetTypeInfo().IsPrimitive。
someType.GetTypeInfo().IsSubclassOf(...)
someType.GetTypeInfo().IsPrimitive
(该using指令是必要的,因为GetTypeInfo()它是 的扩展方法System.Reflection.IntrospectionExtensions)。
GetTypeInfo()
System.Reflection.IntrospectionExtensions