Predefined Surround Templates for C#
This topic lists all predefined surround templates for C# in ReSharper 2021.1. For more information about surround templates, see Surround Code Fragments with Templates
Template | Details |
---|---|
() | Surround the selection with parentheses Scope C# 2.0+, C++ expressions Body ($SELECTION$$END$) Parameters
Before expansion After expansion |
{} | Surround the selection with braces Scope C# 2.0+, C++ statements Body {
$SELECTION$$END$
} Parameters
Before expansion After expansion |
foreach | foreach block Scope C# 2.0+ statements Body foreach ($TYPE$ $VARIABLE$ in $COLLECTION$)
{
$SELECTION$$END$
} Parameters
|
for | Simple "for" loop Scope C# 2.0+ statements Body for (int $INDEX$ = 0; $INDEX$ < $UPPER$; $INDEX$++)
{
$SELECTION$$END$
} Parameters
Before expansion After expansion |
#if | Scope C# 2.0+ except strings, at line start Body #if $expression$
$SELECTION$$END$
#endif Parameters
|
#region | Surround the selection with a region Scope C# 2.0+ except strings, at line start Body #region $name$
$SELECTION$$END$
#endregion Parameters
Before expansion After expansion |
namespace | Add a namespace to the selected code Scope C# 2.0+ types and namespaces Body namespace $name$
{
$END$$SELECTION$
} Parameters
Before expansion After expansion |
tryf | try finally Scope C# 2.0+ statements Body try
{
$SELECTION$
}
finally
{
$END$
} Parameters
|
try | try catch Scope C# 2.0+ statements Body try
{
$SELECTION$
}
catch ($EXCEPTION$ $EX_NAME$)
{
$SELSTART$System.Console.WriteLine($EX_NAME$);
throw;$SELEND$
} Parameters
|
while | while loop Scope C# 2.0+ statements Body while ($expression$)
{
$SELECTION$$END$
} Parameters
Before expansion After expansion |
do | do...while loop Scope C# 2.0+ statements Body do
{
$SELECTION$$END$
} while ($expression$); Parameters
|
if | if statement Scope C# 2.0+ statements Body if ($expr$)
{
$SELECTION$$END$
} Parameters
Before expansion After expansion |
lock | lock statement Scope C# 2.0+ statements Body lock ($expression$)
{
$SELECTION$$END$
} Parameters
Before expansion After expansion |
using | using statement Scope C# 2.0+ statements Body using($resource$)
{
$SELECTION$$END$
} Parameters
Before expansion After expansion |
cast | Cast the selection to a specific type Scope C# 2.0+ expressions Body (($TYPE$)$SELECTION$) Parameters
Before expansion After expansion |