2
考虑这个C#代码:IronPython如何访问C#中定义的公共静态属性?
public static class Graphics {
public static Color white = new Color(255, 255, 255);
}
我可以编译和IronPython的导入此:
>>> import clr
>>> clr.AddReference("Graphics")
>>> import Graphics
>>> Graphics.white
<Color 255,255,255>
但我不能:
>>> import clr
>>> clr.AddReference("Graphics")
>>> from Graphics import *
>>> white
Traceback (most recent call last):
File "/home/dblank/Calico/src/engine.py", line 159, in execute
source.Execute(self.manager.scope)
File "<string>", line 1, in <module>
<type 'exceptions.NameError'>: name 'white' is not defined
有什么我可以做使白色可访问?
是的,它做到了。有没有办法让公共静态属性可见? public static int MyValue {get {} set {}};似乎并没有出现。 – 2011-06-16 13:44:46
哦,什么是.all?我们可以添加到C#中的东西吗? – 2011-06-16 13:47:26