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!

Related Posts

  1. Converting a Visual Studio Class Library Project to a Web Application Project
  2. Changing the default browser for debugging in Visual Studio 2008
  3. Recreate .designer files in Visual Studio 2008

Related posts brought to you by Yet Another Related Posts Plugin.

4 Responses

09.23.09

Right click on name of abstract class or iterface also allow do this

09.23.09

Thanks for noting the alternative method. Personally I prefer keyboard shortcuts wherever possible so that my hands do not need to leave the keyboard.

09.23.09

If you prefer keyboard, I think left alt + . do the same as right click :-)

09.23.09

Great tip! Thanks for passing this along.

Leave Your Response

* Name, Email, Comment are Required

Umbraco Certified Developer
FreshBooks
ElasticHosts: Flexible Servers in the Cloud
SagePay Approved Partner
Microsoft WebsiteSpark