ReSharper 2016.1 Help

Predefined Surround Templates for C#

ReSharper | Templates Explorer | Surround Templates | C#

This topic lists all predefined surround templates for C# in ReSharper 2016.1.1. For more information about surround templates, see Surrounding Code Fragments with Templates

TemplateDetails
()

Surround the selection with parentheses

Scope C++ expressions, C# 2.0+ expressions

Body

($SELECTION$$END$)

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__parentheses__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__parentheses__after

{}

Surround the selection with braces

Scope C++ statements, C# 2.0+

Body

{ $SELECTION$$END$ }

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__braces__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__braces__after

namespace

Add a namespace to the selected code

Scope C# 2.0+ types and namespaces

Body

namespace $NAME$ {$END$$SELECTION$}

Parameters

  • NAME - Gets default namespace for the current file (fileDefaultNamespace)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__namespace__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__namespace__after

if

Put the selection into an if statement block

Scope C# 2.0+ statements

Body

if($END$){$SELECTION$}

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__if__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__if__after

if..else

Put the selection into an if statement block and add an else block

Scope C# 2.0+ statements

Body

if ($COND$) { $SELECTION$ } else { $END$ }

Parameters

  • COND - Suggests variables of the specified type. (variableOfType)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__if..else__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__if..else__after

while

Put the selection into a while loop

Scope C# 2.0+ statements

Body

while($END$){$SELECTION$}

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__while__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__while__after

for

Put the selection into a for loop

Scope C# 2.0+ statements

Body

for($END$){$SELECTION$}

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__for__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__for__after

do..while

Put the selection into a do..while loop

Scope C# 2.0+ statements

Body

do{$SELECTION$}while($END$);

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__do..while__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__do..while__after

#region

Surround the selection with a region

Scope C# 2.0+

Body

#region $END$ $SELECTION$ #endregion

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__region__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__region__after

#if..#endif

Surround the selection with a pair of preprocessor directives

Scope C# 2.0+

Body

#if $END$ $SELECTION$ #endif

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__sharp_if..sharp_endif__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__sharp_if..sharp_endif__after

try..catch

Put the selection into the try block of the try..catch statement

Scope C# 2.0+ statements

Body

try {$SELECTION$} catch ($EXCEPTION$ $EX_NAME$) { $SELSTART$System.Console.WriteLine($EX_NAME$);$SELEND$ }

Parameters

  • EXCEPTION - Evaluates to the specified constant value. (constant)
  • EX_NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • SELECTION - The text selected by the user before invoking the template.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__try..catch__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__try..catch__after

try..finally

Put the selection into the try block of the try..finally statement

Scope C# 2.0+ statements

Body

try {$SELECTION$} finally { $END$ }

Parameters

  • EXCEPTION - Evaluates to the specified constant value. (constant)
  • EX_NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__try..finally__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__try..finally__after

cast

Cast the selection to a specific type

Scope C# 2.0+ expressions

Body

(($TYPE$)$SELECTION$)

Parameters

  • TYPE - Guess type expected at this point (guessExpectedType)
  • SELECTION - The text selected by the user before invoking the template.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__cast__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__cast__after

using

Put the selection into the using statement

Scope C# 2.0+ statements

Body

using($END$){$SELECTION$}

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__using__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__using__after

String.Format

Integrate the selected format string into the String.Format method call

Scope C# 2.0+ expressions

Body

string.Format($SELECTION$, $END$);

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__String.Format__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__String.Format__after

lock

Put the selection into a lock statement

Scope C# 2.0+ statements

Body

lock ($LOCK$) { $SELECTION$$END$ }

Parameters

  • LOCK - Suggests variables of the specified type. (variableOfType)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__lock__before

After expansion
Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__lock__after

Last modified: 19 August 2016