Visual Studio short cut for "SurroundWith" code snippets

By Indranil Chatterjee

Often we need to surround an existing set of lines of code within a block (e.g. try, using, for foreach etc.). Visual Studio provides short cuts to enable that.

Select the relevant section of code and press the key combination CTRL + K,S from the "Surround With:" context menu that appears, select "Visual C#" (or any other relevant category), select the relevant snippet (e.g. for, foreach, using etc.) and hit Enter. Your code will get wrapped by the relevant block.

Visual Studio short cut for "SurroundWith" code snippets  (588 Views)