ReSharper 2016.3 Help

Predefined Surround Templates for C#

ReSharper | Templates Explorer | Surround Templates | C#

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

TemplateDetails
foreach

foreach block

Scope C# 2.0+ statements

Body

foreach ($TYPE$ $VARIABLE$ in $COLLECTION$) { $SELECTION$$END$ }

Parameters

  • COLLECTION - Show basic code completion list at the point where the variable is evaluated (complete)
  • TYPE - Suggest type for a new variable declared in the template (suggestVariableType)
  • VARIABLE - 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.
for

Simple "for" loop

Scope C# 2.0+ statements

Body

for (int $INDEX$ = 0; $INDEX$ < $UPPER$; $INDEX$++) { $SELECTION$$END$ }

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • UPPER - no macro
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__for__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__for__after.png

#if (Imported Visual C# Snippets)

Code snippet for #if

Scope C# 2.0+ except strings, C# 2.0+

Body

#if $expression$ $SELECTION$$END$ #endif

Parameters

  • expression - Evaluates to the specified constant value. (constant)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
#region (Imported Visual C# Snippets)

Code snippet for #region

Scope C# 2.0+ except strings, C# 2.0+

Body

#region $name$ $SELECTION$$END$ #endregion

Parameters

  • name - Evaluates to the specified constant value. (constant)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__region__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__region__after.png

namespace (Imported Visual C# Snippets)

Code snippet for namespace

Scope C# 2.0+ types and namespaces

Body

namespace $name$ { $END$$SELECTION$ }

Parameters

  • name - Evaluates to the specified constant value. (constant)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__namespace__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__namespace__after.png

tryf (Imported Visual C# Snippets)

Code snippet for try finally

Scope C# 2.0+ statements

Body

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

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
try (Imported Visual C# Snippets)

Code snippet for try catch

Scope C# 2.0+ statements

Body

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

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.
while (Imported Visual C# Snippets)

Code snippet for while loop

Scope C# 2.0+ statements

Body

while ($expression$) { $SELECTION$$END$ }

Parameters

  • expression - Evaluates to the specified constant value. (constant)
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.

Before expansion

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__while__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__while__after.png

do (Imported Visual C# Snippets)

Code snippet for do...while loop

Scope C# 2.0+ statements

Body

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

Parameters

  • expression - 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.
if (Imported Visual C# Snippets)

Code snippet for if statement

Scope C# 2.0+ statements

Body

if ($expression$) { $SELECTION$$END$ }

Parameters

  • expression - 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

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__if__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__if__after.png

lock (Imported Visual C# Snippets)

Code snippet for lock statement

Scope C# 2.0+ statements

Body

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

Parameters

  • expression - 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

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__lock__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__lock__after.png

using (Imported Visual C# Snippets)

Code snippet for using statement

Scope C# 2.0+ statements

Body

using($resource$) { $SELECTION$$END$ }

Parameters

  • resource - 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

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__using__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__using__after.png

()

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

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__parentheses__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__parentheses__after.png

{}

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

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__braces__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__braces__after.png

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

/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__cast__before.png

After expansion
/help/img/dotnet/2016.3/Reference__Options__Templates__Surround_With_Templates__Predefined__CSharp__cast__after.png

Last modified: 15 February 2017