I have an interface IMyInterface
, which currently have only one member method MyMethod1
having return type void. I have this interface in more than 50 classes, now suppose I change the return type of the interface method from void
to string
.
How to change the method signature in all the classes implementing the interface. I know Visual studio IDE does that with option to replace all. Just curious to know if there is any other method.
I'd just change the method signature in the interface, and follow all the error messages you get.
After all, in each method you're going to need to decide what to return, so you should really look at each of those classes individually. You may well find that refactoring tools would offer the option of changing the signature and adding a a return null;
statement at the end of each method, but I'd say that that aspect of the change is likely to take far less effort than really working out what each implementation should return - and if you do it all manually, you're less likely to accidentally leave one implementation with that "default" (quite possibly inappropriate) return.
See more on this question at Stackoverflow