.net IronPython:从脚本中调用不带参数的C#函数
我试图在C#应用程序中使用IronPython作为脚本语言。脚本必须使用主应用程序提供的功能(在应用程序或外部库中实现) 虽然这对于只有输入参数的“简单”函数非常有效(就像我发现的任何其他示例中一样),但对于没有参数的函数,这是失败的 示例(C#代码): 然后是IronPython脚本。我希望该值应该设置为3.14,但只能设法得到0.0.net IronPython:从脚本中调用不带参数的C#函数,.net,ironpython,.net,Ironpython,我试图在C#应用程序中使用IronPython作为脚本语言。脚本必须使用主应用程序提供的功能(在应用程序或外部库中实现) 虽然这对于只有输入参数的“简单”函数非常有效(就像我发现的任何其他示例中一样),但对于没有参数的函数,这是失败的 示例(C#代码): 然后是IronPython脚本。我希望该值应该设置为3.14,但只能设法得到0.0 import clr import System ret,value = getValue() print("getValue -> %d => %
import clr
import System
ret,value = getValue()
print("getValue -> %d => %s" % (ret, value)) # => output "getValue -> 42 => 0.0
value = clr.Reference[System.Single]()
ret = getValue(value)
print("getValue -> %d => %s" % (ret, value)) # => output "getValue -> 42 => 0.0
我错过什么了吗
注:
import clr
import System
ret,value = getValue()
print("getValue -> %d => %s" % (ret, value)) # => output "getValue -> 42 => 0.0
value = clr.Reference[System.Single]()
ret = getValue(value)
print("getValue -> %d => %s" % (ret, value)) # => output "getValue -> 42 => 0.0