DancesWithBamboo DancesWithBamboo - 29 days ago 18
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

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
{
}