如何在 IronPython 中检查类型相等性?
我需要 IronPython 中与以下 C# 代码等效的代码:
if (x.GetType() == typeof(xType))
或者
if (x is xType)
如何在 IronPython 中检查类型相等性?
我需要 IronPython 中与以下 C# 代码等效的代码:
if (x.GetType() == typeof(xType))
或者
if (x is xType)
from System import *
if x.GetType() == Type.GetType(xType):
说 C 是一个静态类,不是完全限定的,而是导入到 Iron python 脚本中的 x 是 C 的一个实例,而 ABC 是完全限定的名称
为什么这些不起作用?
x.GetType() == Type.GetType("A.B.C")
或者
x is Type.GetType("A.B.C")
或者
x is C
或者
x.GetType() == Type.GetType(C)