Automatically insert empty bodies of the base method

If I have a base class with some abstract methods, is there a way to let Visual Studio automatically insert empty bodies of methods that should be implemented for me in new derived classes (e.g. with Eclipse and Java)

Same:

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();
    }
}
+3
source share
3 answers

Yes and No, to some extent.

1- If the base class is abstract, then when VS shows an intelligent tag that provides a stub implementation for all abstract methods, but not virtual methods. This is the same for implementing interfaces.

enter image description here

2- . override, intellisense. , .

+10

, , ,

throw new NotImplementedException();

VisualStudio → ImplementInterface

+1

Visual Studio . . , IntelliSense overridabl.

, , , , . , .

+1

All Articles