You cannot avoid implementing all interface methods. If you inherit an interface, you must execute it.
In some situations, some interface methods may not have a useful implementation for a particular class. Once you conclude that you must implement the interface, despite this, there are some things you can do:
You can implement the method as doing nothing. If the class is already doing what is expected without it, you can simply accept the method call and silently do nothing.
You can throw NotSupportedExceptionit if some result is expected by calling a method that the class cannot execute. Naturally, this should be done only if the method is not critical for using the interface.
, . , , , .
, , , .
Multiply A ( ICanCalc):
A obja = new A();
ICanCalc infa = new A();
infa.Multiply();
obja.Multiply();
, , , :
(ICanCalc)obja.Multiply();