ReSharper comes with a number of predefined 'Surround With' Templates. You can use them as is or customize them to best suit your programming needs and your programming style (for details see Managing and Sharing 'Surround With' Templates).
| Name | Specification |
|---|---|
| if | Allows to place the selected code inside a conditional execution block. Consider the following code:
Selecting the code, pressing Ctrl + Alt + J and choosing if template yields:
The caret is positioned so that you can immediately start typing the logical condition providing execution of the surrounded code. |
| while | Places the selected code inside a while loop. The behavior mirrors that of if template with straightforward substitutions of while in place of if. |
| for | Places the selected code inside a for loop. The behavior mirrors that of if template with straightforward substitutions of for in place of if. |
| do..while | Places the selected code inside a do..while loop. Surrounding the same code example as in the description of if template yields:
|
| lock | Places the selected code inside a mutually exclusive execution block (C# lock statement). The behavior mirrors that of if template with straightforward substitutions of lock in place of if. |
| #region | Marks the selected code as a C# region. Places the caret so that you can immediately start typing a preprocessor message for the new region. Surrounding the same code example as in the description of if template yields:
|
| {} | Converts the selected code into a C# compound statement by surrounding it with curly braces {}. |
| try..catch | Places the selected code into a try..catch block. See detailed example here. |
| try..finally |
Places the selected code into a
|
| cast | Consider the following code example:
Clearly, the variable
The caret is conveniently positioned so that you can immediately start typing the desired type name. |
| using | |
| String.Format |
Using 'Surround With' Templates | Managing and Sharing 'Surround With' Templates