开发者

Accessing protected members of .NET type in Iron Python

I 开发者_JS百科have a .NET type 'MyClass' with a protected method that takes in an out parameter. For example:

protected bool MyMethod(out string value)

I am able to call this method on a 'MyClass' object created in Iron Python script. But however, the out variable 'value' is 'None' even if it is assigned some value in the method.

Now if I make it public, then all is fine.

Is this the expected behavior? Why does Iron Python allow protected methods to be called? Is it a conscious decision?

I am using Iron Python 2.0.1


I believe this is intended behaviour, as MyMethod is effectively private to MyClass, so you are not supposed to be able to access it at all, not even on IronPython.

You can use reflection (InvokeMember) though to get arround this.


Looking around, it seems like this is indeed intended behaviour.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜