yes I know, this seems to be the same question as asked thousands of times before.
But no, it’s not really – at least I think so.
I use IronPython and want to call a C# method:
bool GetClassInstance<T>(out T myClassInstance)
Calling this function via python would look like:
myClassInstance = None
myInstance.GetClassInstance[ClassType](myClassInstance)
The problem is following error message:
expected StrongBox[ClassType], got NoneType (ArgumentTypeException)
Now I do have two questions:
- Is it possible to get this to run?
- How???
Thanks a lot!!
To call methods that have
outparameters, just omit the argument (as you’re not really passing a value) and its return value will be a tuple with the result of the function (if it was non-void) and theoutvalues in the order they are defined.In the case of
refparameters, pass in the argument and it will still be returned in the tuple. Any mutations on the object will work as expected.e.g.,
Here’s a test I did so you could see how to call the different variations.
Alternatively if you wanted to use the C# style call, you need to pass in a
clr.Reference[T]object in place of theout/refparameter to hold the value. You can access that value through theValueproperty.