Friday, November 2, 2007

Some common code Snippets in visual studio (prop,ctor,try, etc.)

Probably every one knows about it but still want to share a simple feature that I though really good is code snippet. it’s a help tool to generate small portion of code using key word then tab.

image

to use this just type “ctor” in your class and then press tab, this will automatically generate code for you. bellow some common snippet key word is given.

  • ctor (constructor)
  • prop (property)
  • propg (read only property)
  • using (using block)
  • while,do (for loop block)
  • try, tryf (for try catch and try finally block)

There are more, you can find all of them in intelligence context menu. Lets finish this post by another information worth knowing is that the “Surround With” and “Insert Snippet” content menu item. You can also use this to warp your codes with region conditional pre-compiler switch and many more.

image

Please visit the resource bellow on MSDN to know more about how to use custom snippet. It has full resource how to customize the snippet feature and you can create and distribute your own code snippet.

http://msdn.microsoft.com/en-us/library/ms165392%28v=vs.80%29.aspx