Post Pic

Shortcut to Implement Abstract Class or Interface in Visual Studio

For me every day is a school day and every day I learn something new. Today the light shined brightly for me when I discovered a great time saving shortcut in Visual Studio to implement an Abstract Class or Interface in Visual Studio. Using the shortcut will populate all of the abstract class method signatures for you.

CTRL + > or you can use  SHIFT + ALT + F10

Here is an example of a new custom Application tree I was implementing for the Umbraco CMS:

namespace ProlificNotion.Umbraco

{

public class MyNewTree : umbraco.cms.presentation.Trees.BaseTree
{

}
}

With your cursor at the end of the class signature you can then press CTRL + > or SHIFT + ALT + F10 and you will get a smart tag offering to implement the abstract class or interface, hit enter and the result is as follows:

namespace ProlificNotion.Umbraco
{
public class MyNewTree : umbraco.cms.presentation.Trees.BaseTree
{

protected override void CreateRootNode(ref umbraco.cms.presentation.Trees.XmlTreeNode rootNode)
{
throw new System.NotImplementedException();
}

public override void Render(ref umbraco.cms.presentation.Trees.XmlTree tree)
{
throw new System.NotImplementedException();
}

public override void RenderJS(ref System.Text.StringBuilder Javascript)
{
throw new System.NotImplementedException();
}
}
}

A simple example of something that can be a huge time saver particularly when the inherited class or interface has a large number of methods to implement!

Umbraco Certified Developer
SagePay Approved Partner
Creative Market