0
を使用してC#でPythonのクラスにメソッドから値を読みますクラス: クラス形状(オブジェクト):は、私は</p> <p>誰もが、私はこれを達成するために、次の何をすべきか知っているC#で、このPythonのクラスから面積法を読みたいIronPythonの
def __init__(self,x, y):
self.x = x
self.y = y
def area(self):
return self.x * self.y
C#コード:
ScriptEngine engine1 = Python.CreateEngine();
ScriptSource source1 = engine1.CreateScriptSourceFromFile("C:\\C#Projects\\ExcelAddIn\\ExcelAddIn\\Shape.py");
ScriptScope scope1 = engine1.CreateScope();
source1.Execute(scope1);
dynamic class_object1 = scope1.GetVariable("Shape");
dynamic class_instance1 = class_object1();
Thx、これはうまくいくようです。 – user2910705
しかし、その後私は 'area'メソッドの値を読み取ることができますか? – user2910705
'class_instance1.area()' – Haytam