C# 使用pythonnet传递和检索对象

C# 使用pythonnet传递和检索对象,c#,python,python.net,python-netifaces,pythonnet,C#,Python,Python.net,Python Netifaces,Pythonnet,通常,如何使用pythonnet传递和返回对象。例如,如果我要返回一个数字,则此操作非常有效: dynamic par = Python.Runtime.Py.Import("mypackage.pythonfile"); var t = par.GetPPMError(100, 100.001); 在这里,我导入一个名为“pythonfile”的文件包 这将使用pythonfile.GetPPMError()方法返回一个数字 我如何做到这一点: //C# arrays var doub

通常,如何使用pythonnet传递和返回对象。例如,如果我要返回一个数字,则此操作非常有效:

 dynamic par = Python.Runtime.Py.Import("mypackage.pythonfile");
 var t = par.GetPPMError(100, 100.001);
在这里,我导入一个名为“pythonfile”的文件包

这将使用pythonfile.GetPPMError()方法返回一个数字

我如何做到这一点:

 //C# arrays var double x = new double[500]
 //C# array var double y = new double[500]
 dynamic par = Python.Runtime.Py.Import("mypackage.pythonfile");
 var p = par.GetPeak(x,y)
其中,GetPeak是“pythonfile.py”中的python方法,p是一个类,例如:

class Peak:
def __init__(self):
    self.FileID = ""
    self.RT = 0
    self.Intensity = 0
    self.MZ = 0

然后可以将其转换为C#对象?

对于数组,需要编写一些代码,例如: