ReSharper 2019.1 Help

Predefined Surround Templates for C#

ReSharper | Templates Explorer | Surround Templates | C#

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

Template

Details

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 executed 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
Reference Options Templates Surround With Templates Predefined CSharp for before

After expansion
Reference Options Templates Surround With Templates Predefined CSharp for after

#if (Imported Visual C# Snippets)

Scope C# 2.0+ except strings, at line start

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)

Surround the selection with a region

Scope C# 2.0+ except strings, at line start

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
Reference Options Templates Surround With Templates Predefined CSharp region before

After expansion
Reference Options Templates Surround With Templates Predefined CSharp region after

namespace (Imported Visual C# Snippets)

Add a namespace to the selected code

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
Reference Options Templates Surround With Templates Predefined CSharp namespace before

After expansion
Reference Options Templates Surround With Templates Predefined CSharp namespace after

tryf (Imported Visual C# Snippets)

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)

try catch

Scope C# 2.0+ statements

Body
try { $SELECTION$ } catch ($EXCEPTION$ $EX_NAME$) { $SELSTART$System.Console.WriteLine($EX_NAME$); throw;$SELEND$ }
Parameters
  • EXCEPTION - Evaluates to the specified constant value. (constant)

  • EX_NAME - When executed 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)

while loop

Scope C# 2.0+ statements

Body
while ($expression$) { $SELECTION$$END$ }
Parameters
  • expression - Show basic code completion list at the point where the variable is evaluated (complete)

  • 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

do (Imported Visual C# Snippets)

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)

if statement

Scope C# 2.0+ statements

Body
if ($expr$) { $SELECTION$$END$ }
Parameters
  • expr - Show basic code completion list at the point where the variable is evaluated (complete)

  • 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

lock (Imported Visual C# Snippets)

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
Reference Options Templates Surround With Templates Predefined CSharp lock before

After expansion
Reference Options Templates Surround With Templates Predefined CSharp lock after

using (Imported Visual C# Snippets)

using statement

Scope C# 2.0+ statements

Body
using($resource$) { $SELECTION$$END$ }
Parameters
  • resource - Show basic code completion list at the point where the variable is evaluated (complete)

  • 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
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
Last modified: 1 August 2019