Python .Net function call with reference parameter

I am using IronPython in VS2012 and trying to call a .Net function that accepts Ref ,

lib.dll

public int GetValue(ref double value)
{
  ...
}

Python:

import clr
clr.AddReference('Lib.dll')
from LibDll import *

value =0.0
x = GetValue(value)

Something is missing for me, in C # we use reftogether with the variable name, how about Python?

+4
source share
1 answer

There are two ways to call methods with out or ref parameters from IronPython.

In the first case, the call is processed by automatic sorting. The return value and the modified refs are wrapped in a tuple and (if there is 15.1 as an example of a double to be passed) can be used as:

(returned, referenced) = GetValue(15.1)

clr-:

refParam = clr.Reference[System.Double](15.1)
result = GetValue(refParam)
+4

All Articles