MSVS 2012, C #
class main : BaseClass, IMainInterface {} How to prove to the compiler that the methods of the same name and from BaseClass and IMainInterface are one and the same and you don’t need to re-sculpt the implementation, that you only have to swear on new methods that should be on IMainInterface but not in BaseClass ?
Approximately what I want, while I must inherit from BaseClass (so as not to break compatibility with someone else's code)
interface IMyInterface { void Print(string str); void SpecificIMethod(); } class BaseClass { public void Print(string str) { Console.WriteLine(str); } } class MyClassA : BaseClass, IMyInterface { public void SpecificIMethod() {} } class MyClassB : BaseClass, IMyInterface { public void SpecificIMethod() {} } class Program { static void Main(string[] args) { var myClass = (IMyInterface)new MyClassA(); myClass.Print("my message"); myClass.SpecificIMethod(); Console.ReadKey(); } }