Python NET调用C#方法并将null作为参数传递

Python NET调用C#方法并将null作为参数传递,c#,python,python-3.x,null,python.net,C#,Python,Python 3.x,Null,Python.net,我有下面的静态C#方法 我想使用pythonnet包从Python调用它 import clr clr.AddReference("MyCSharp") import System from MyCSharp import MyStaticClass t1 = MyStaticClass.MyTestMethod([1., 2.], [3., 4.]) # works 但是我如何才能为第一个或第二个参数传递null t2 = MyStaticClass.MyTestMethod(None,

我有下面的静态C#方法

我想使用pythonnet包从Python调用它

import clr
clr.AddReference("MyCSharp")
import System
from MyCSharp import MyStaticClass

t1 = MyStaticClass.MyTestMethod([1., 2.], [3., 4.]) # works
但是我如何才能为第一个或第二个参数传递
null

t2 = MyStaticClass.MyTestMethod(None, [3., 4.]) # fails! TypeError: No method matches given arguments

t3 = MyStaticClass.MyTestMethod([1., 2.], None) # fails! TypeError: No method matches given arguments
我知道我可以为参数
a
或be
b
null
的情况添加额外的C方法

public static double[] TestMethodWithANull(double[] b)
{ return TestMethod(null, b); }

public static double[] TestMethodWithBNull(double[] a)
{ return TestMethod(a, null); }

但是我更愿意将一个
null
从Python传递给C#方法。例如,在MATLAB中,我可以通过传递一个
[]

来实现这一点,另一个替代方法可能是:
公共静态双[]测试方法(双[]a=null,双[]b=null)
public static double[] TestMethodWithANull(double[] b)
{ return TestMethod(null, b); }

public static double[] TestMethodWithBNull(double[] a)
{ return TestMethod(a, null); }