你如何实现IronPython的接口? [英] How do you implement an interface in IronPython?

查看:141
本文介绍了你如何实现IronPython的接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

附带了IronPython的2.0.1的FAQ,列出了以下内容:

The FAQ which comes with the IronPython 2.0.1, lists the following:

您可以定义在C#中的接口,构建   这些成一个DLL,然后实现   这些接口在Python code作为   以及通过Python的对象   实现的接口为C#code。

You can define interfaces in C#, build those into a DLL, and then implement those interfaces in Python code as well as pass the python objects that implement the interfaces to C# code.

我用Google搜索和Google搜索和Google搜索,但没有找到如何做到这一点。有人可以帮忙吗?

I have googled and googled and googled, but not found how to do this. Can someone help?

谢谢

罗希特

推荐答案

我不知道这一点,但它看起来像你可以使用Python的常规继承语法做到这一点:

I'm not sure of this, but it looks like you could do it with the regular inheritance syntax of python:

class SomeClass (ISomeInterface):
    def SomeMethod(self, parameter):
        pass

编辑:好吧,我只是测试它并确认,你可以在IronPython中实现一个接口,这样一来。只是继承接口,实现它的方法,就像任何其他类的方法,并享受!

Ok, I just tested it and confirmed that you can implement an interface in IronPython this way. Just "inherit" the interface, implement its methods as you would any other class method, and enjoy!

这篇关于你如何实现IronPython的接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆