次の方法で共有


Surround with a Code Snippet (C# Only)

Keyboard:  CTRL + K, CTRL + S
Menu:  Edit | IntelliSense | Surround With
Command:  Edit.SurroundWith
Versions:  2008,2010
Published:  4/21/2010
Code:  vstipEdit0052

 

 

This is one that even people who know about snippets tend to forget.  You can actually put a snippet AROUND existing code.  Assuming you have some code selected:

clip_image002

 

Just press CTRL + K, CTRL + S:

clip_image004

 

Then type the statement you want to surround the code with.  In this case, I’ll use an “if” statement:

clip_image006

 

Hit your TAB key once and you get your result:

clip_image008

 

Now you can put in your condition and any additional logic you want.  Pretty cool stuff!