Code Snippets

Code snippets are pre-authored pieces of code that are ready to be inserted into your application with Visual Studio 2005. These code snippets increase productivity by reducing the amount of time spent typing repetitive code or searching for samples. Visual Studio 2005 includes a number of code snippets for you to use. You can also use the IntelliSense Code Snippet XML schema to create your own Visual Basic, Visual C#, Visual J#, or XML code snippets. You can even download code snippets from--and share your own with--other users in the community from directly within the Code Snippet Manager. To manage the folders in which you store code snippets, or to download, add, or share new snippets, click Code Snippet Manager on the Tools menu.

Code snippets function as an Intellisense feature. To display a list of available code snippets, right-click the active document in the Code Editor and then click Insert Snippet on the shortcut menu. Click the name of the snippet you want, and the code is inserted into the editor, ready for you to modify as needed. Sometimes the code that is inserted may include gray highlighted “template” areas that require further customization.

Inserting a code snippet in Visual Basic.