I'm having the following static C# method
public static bool TryParse (string s, out double result)
which I would like to call from Python using the Python NET package.
import clr
from System import Double
r0 = Double.IsNaN(12.3) # works
r1, d1 = Double.TryParse("12.3") # fails! TypeError: No method matches given arguments. This works in IronPython.
d2 = 0.0
r2, d2 = Double.TryParse("12.3", d2) # fails! TypeError: No method matches given arguments
Any idea?
Update
I found the following answer, see https://mcmap.net/q/1772626/-how-to-use-a-net-method-which-modifies-in-place-in-python.
CPython using PythonNet does basically the same thing. The easy way to do out parameters is to not pass them and accept them as extra return values, and for ref parameters to pass the input values as arguments and accept the output values as extra return values.
This would claim that r1, d1 = Double.TryParse("12.3")
should work, but it doesn't.
r2, d2 = Double.TryParse("12.3", d2)
, so d2 is defined. I'll edit my question. Sorry my fault. I still get the the following error:TypeError: No method matches given arguments
. – Bugloss