15

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 interfaces in Python code as well as pass the python objects that implement the interfaces to C# code.

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

1 Answer 1

20

You can do it with the regular inheritance syntax of Python:

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

Just "inherit" the interface, implement its methods as you would any other class method, and enjoy!

Sign up to request clarification or add additional context in comments.

1 Comment

To implement properties in an interface, you would use def get_SomeProperty(self): and def set_SomeProperty(self):

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.