Automatically generate implementations of base class methods

后端 未结 7 825
我在风中等你
我在风中等你 2021-02-02 07:33

Is there a shortcut of some kind in C# (VS 2008) to automatically implement the virtual and abstract base class methods in a derived class?

7条回答
  •  南方客
    南方客 (楼主)
    2021-02-02 08:15

    For virtual methods, you can type override and then a space. Intellisense should offer you a list of options.

    For abstract methods and properties, you can use the smart tag on the base class or interface (also, Ctrl+. or Shift+Alt+F10 will show the smart tag menu) to generate the concrete items.

    For example, in the following code snippet, you could place the caret at the end of INotifyPropertyChanged and press Ctrl+. to then select Implement Interface, and the PropertyChanged event would be added to MyClass:

    class MyClass : INotifyPropertyChanged
    {
    }
    

提交回复
热议问题