This post gives you idea about Code Snippets in Visual Studio and how you can use them. Code snippets in Visual Studio are useful in reducing typing effort required to input your code. Code Snippets help in various ways in simplifying your work if you can remember to use them instead of typing the actual code. Code Snippets are present in Visual Studio 2005, 2008 & 2010
To use code snippets, instead of typing the code you will type a shortcut, actually a word and press Tab key, to insert the actual code to which the shortcut is linked with.
For example, to type the below code..
for (int i = 0; i < length; i++)
{
}
You can type "for" and then press Tab..you will then get the code inserted into the code window as shown below..
Now you can see that “i” is highlighted, this means you can type a name for the loop variable, once you renamed it, you can press Tab to select “length” and rename it or specify what should be there, like, list.Count, etc. Once done, press enter to place the cursor inside the for loop braces.
So as you can see whenever you need to write a for loop you can use this code snippet and save time. There are many code snippets you can use.
Also you can right click code editor and select Insert Snippet...(Ctrl+K, Ctrl+X) and choose the snippet you need from the list. You can also select set of code lines and right click and select Surround With...(Ctrl+K, Ctrl+S) option to put the selected code into the snippet that you will insert, like, a try..catch block.