0

I have and interface with 5 mthods.

I want to add a 6th method, but I would like to avoid having to manually add the method to each claas I have that uses the interface.

Can I either:

  1. Tell interface the class does NOT have to be implemented. OR
  2. Have VS add empty method to each derived class automatically.

Is either of the above possible?

ManInMoon
  • 6,795
  • 15
  • 70
  • 133
  • 2
    Use a class implementing the 6th method. Let all classes derive from it. – Patrick Hofman Dec 16 '15 at 10:33
  • 1
    Create a new interface, add it to classes you want – Hamid Pourjam Dec 16 '15 at 10:34
  • http://stackoverflow.com/questions/17844122/how-do-you-auto-implement-an-interface-in-c-sharp-4-0-visual-studio-2012 – Mukund Dec 16 '15 at 10:38
  • Will all the classes that implement your interface have different implementations of that method? Do all the classes even require the method? Seems like a design issue if you do not want that method to be implemented in all classes, in this situation you want to extract this functionality to a separate interface which is only implemented on the classes that require it. Otherwise if you are going to implement them you'll have to go through each one manually and implement the interface (ctrl+.) when the cursor is on the interface of the class. – Stephen Ross Dec 16 '15 at 10:41
  • @Mukund - is there an implement interface ALL? - I have a lot of classes – ManInMoon Dec 16 '15 at 11:02
  • put the cursor on interface name which you want to implement and then do 'ctrl+'. This will implement this interface in all the class which are implementing this. – Mukund Dec 16 '15 at 11:38

0 Answers0