I was wondering: can an interface inherit from another class?
I’m trying to let an interface inherit from the MarshalByRefObject.
My intent is that all classes implementing the interface also inherit from that class.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it cannot.
An interface can only specify other interfaces that must be implemented. This is done by using the same syntax as inheritance, but it’s something different.
You could use an abstract class instead that inherits from
MarshalByRefObjectand and requires your interfaces to be implemented.Depending on how you need to enforce your requirement, generic constraints might help, too. For generic type parameters, you can set class constraints, like
class Argh<T> where T : MarshalByRefObject, ISomeInterface.