从IronPython调用C#对象

2024-06-13 05:09:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我有下面的C代码来编译它我的数学.dll装配。在

namespace MyMath {
    public class Arith {
        public Arith() {}
        public int Add(int x, int y) {
            return x + y;
        }
    }
}

我有下面的IronPython代码来使用这个对象。在

^{pr2}$

当我用IronPython运行这段代码时,我得到以下错误。在

Traceback (most recent call last):
  File ipycallcs, line unknown, in Initialize
NameError: name 'Arith' is not defined

可能出了什么问题?在

已添加

arith=arith()应该是arith=我的数学。阿里斯()


Tags: 对象代码addreturn数学publicnamespaceclass