Press "Ctrl + K, S" and then in drop down menu double click "try" - it's a "try-catch" template.
try – A try block is used to encapsulate a region of code. If any code throws an exception within that try block, the exception will be handled by the corresponding catch. catch – When an exception occurs, the Catch block of code is executed. This is where you are able to handle the exception, log it, or ignore it.
Mark your code
Right-click
Select Surround with...
Double-click try
Mark your code using Shift, Ctrl + A, or whatever works for you
Press Menu key
/ Application key
(alternatively Shift + F10)
Type S
Type T
Press Enter or Tab
Mark your code using Shift, Ctrl + A, or whatever works for you
Press Ctrl + K, followed by CTRL + S
Type T
Press Enter or Tab
type try
then hit Tab,Tab
2 x Tab activates a code snippet.
type tryf
, Tab,Tab to activate the try..finally
block instead
If you don't want to remove your fingers from the keyboard, you can hit Ctrl + K, Ctrl + S, then T, then Enter. That's basically what he said, but without using the mouse.
http://msdn.microsoft.com/en-us/library/6hf704tz%28VS.80%29.aspx
Have you tried using snippets?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With