Visual Studio - automatically implement all inherited methods from an interface

后端 未结 5 883
借酒劲吻你
借酒劲吻你 2021-02-18 21:19

Let\'s say we have a class called MyClass.

public class MyClass

We also have an interface like so:

public interface MyInterface         


        
相关标签:
5条回答
  • 2021-02-18 21:45

    In Visual Studio 2013 you can right click on the interface and select "Implement Interface". It will generate all the methods for you with the NotImplmentedException.

    0 讨论(0)
  • 2021-02-18 21:47

    For C#, you can right click the 'MyInterface' and choose 'Implement Interface' from the context menu. I believe there is a similar (but slightly different) shortcut for VB.NET.

    0 讨论(0)
  • 2021-02-18 21:55

    You can simply use shortcut "CTR+." to do that. Position your cursor on MyInterface of "public class MyClass: MyInterface" line, and press "CTR+.", a context menu will show up with "Implement Interface ...".

    0 讨论(0)
  • 2021-02-18 21:55

    To automatically implement all inherited methods from an interface:

    C# : Just right click on interface(Prefix with 'I') name and select implement interface option.

    VB.NET : Just point your cursor after interface(Prefix with 'I') name and hit enter.

    Enjoy!!!

    0 讨论(0)
  • 2021-02-18 21:57

    This is a job for macros in Visual Studio. Here is an example that does a similar thing for abstract classes. It should be enough to get you going.

    0 讨论(0)
提交回复
热议问题