Visual Studio 2005–Code Snippets

One of the new features that comes with Visual Studio 2005 is Code Snippets is the ability to create code snippets, small blocks of code that are easily reusable as you develop. Think of it as the developer’s cook book. Creating your own code snippets is quite easy, there’s even a code snippet for doing that.

You can use code snippets to type a short alias, and then expand it into a common programming construct. For example, the for code snippet creates an empty for loop. Some code snippets are surround-with code snippets, which enable you to select lines of code, then choose a code snippet which will incorporate the selected lines of code. For example, selecting lines of code then activating the for code snippet creates a for loop with those lines of code inside the loop block. Code snippets can make writing program code quicker, easier, and more reliable.

Some of the code snippets have logic built-in, for example the constructor code snippet: it knows the name of the class for which you’d like to generate a constructor. If you would like to create your own code snippets with more advanced functionality you have to take a look at the Function element in the Literal element of the code snippet.

There is a gallery of free code snippets:

More information about code snippets found here.

Leave a Reply