DancesWithBamboo DancesWithBamboo - 11 months ago 87
C# Question

Automatically generate implementations of base class methods

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?

Answer Source

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