Say I have an interface IFoo and I want all subclasses of IFoo to override Object’s ToString method. Is this possible?
Simply adding the method signature to IFoo as such doesn’t work:
interface IFoo { String ToString(); }
since all the subclasses extend Object and provide an implementation that way, so the compiler doesn’t complain about it. Any suggestions?
I don’t believe you can do it with an interface. You can use an abstract base class though: