If I have a base class with some abstract methods, is there a way to let Visual Studio automatically insert the empty bodies of the methods that need to be implemented for me in new derived classes (like you can with Eclipse and Java)?
Like so:
public abstract class foo
{
public virtual void bar()
{
doSomething();
}
}
public class Derived : foo
{
//somehow tell VS to insert this without me having to write everything
public override void bar()
{
base.bar();
}
}
Yes and No, to some extent.
1- If the base class is abstract then when VS will show a smart tag which provide stub implementations for all the abstract methods, but not the virtual methods. This is the same for implementing interfaces.
2- For virtual methods, you do not need to type everything. In the derived class you can just type the
overridekeyword and then select the relevant method to override from the intellisense list. The list will filter to the methods that do not already have overrides within the class.