The prop snippet and Visual Studio 2008

by Henrik Stenbæk 15. March 2008 19:34

In Visual Studio 2005 typing "prop[tab][tab]" will give you something like this:

vs2005

This is fine and one of the most time saving code snippets ever invented. If one type the same in Visual Studio 2008 it's ends out a little different:

vs2008

This is due to the new Automatic Properties Feature in .NET 3.0/VS 2008. This is somehow also fine as long as one don't want to maintain a .NET 2.0 project with VS 2008, doing this will end up with an compile time error saying:".. must declare a body because it is not marked abstract or extern"

must declare a body because it is not marked abstract or extern

A solution to this is to download this file:

prop.zip (604,00 bytes)

place in your "My Code Snippets" folder:

C:\users\*your user name*\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets

Now you can simply type propp[tab][tab] in Visual Studio 2008 and get the VS 2005 style property snippet. Why propp? After typing porp your finger is over the [p] button so I thought it would be the fastest solution. If you don't like it: open the prop.snippet file with Visual Studio or any text editor and edit the shortcut tag:

<Shortcut>propp</Shortcut>

Currently rated 4.5 by 6 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories: Source code

Comments

Comments are closed