How do you implement an interface in IronPython?

前端 未结 1 1222
忘了有多久
忘了有多久 2021-02-07 11:20

The FAQ that comes with IronPython 2.0.1 says the following:

You can define interfaces in C#, build those into a DLL, and then implement those interfa

相关标签:
1条回答
  • 2021-02-07 12:02

    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
    

    EDIT: 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!

    0 讨论(0)
提交回复
热议问题