Predefined Surround Templates for 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 Bodyforeach ($TYPE$ $VARIABLE$ in $COLLECTION$)
{
$SELECTION$$END$
} Parameters
|
for | Simple "for" loop Scope C# 2.0+ statements Bodyfor (int $INDEX$ = 0; $INDEX$ < $UPPER$; $INDEX$++)
{
$SELECTION$$END$
} Parameters
After expansion |
| Scope C# 2.0+ except strings, at line start Body#if $expression$
$SELECTION$$END$
#endif Parameters
|
| Surround the selection with a region Scope C# 2.0+ except strings, at line start Body#region $name$
$SELECTION$$END$
#endregion Parameters
After expansion |
| Add a namespace to the selected code Scope C# 2.0+ types and namespaces Bodynamespace $name$
{
$END$$SELECTION$
} Parameters
After expansion |
| try finally Scope C# 2.0+ statements Bodytry
{
$SELECTION$
}
finally
{
$END$
} Parameters
|
| try catch Scope C# 2.0+ statements Bodytry
{
$SELECTION$
}
catch ($EXCEPTION$ $EX_NAME$)
{
$SELSTART$System.Console.WriteLine($EX_NAME$);
throw;$SELEND$
} Parameters
|
| while loop Scope C# 2.0+ statements Bodywhile ($expression$)
{
$SELECTION$$END$
} Parameters
After expansion |
| do...while loop Scope C# 2.0+ statements Bodydo
{
$SELECTION$$END$
} while ($expression$); Parameters
|
| if statement Scope C# 2.0+ statements Bodyif ($expr$)
{
$SELECTION$$END$
} Parameters
After expansion |
| lock statement Scope C# 2.0+ statements Bodylock ($expression$)
{
$SELECTION$$END$
} Parameters
After expansion |
| using statement Scope C# 2.0+ statements Bodyusing($resource$)
{
$SELECTION$$END$
} Parameters
After expansion |
cast | Cast the selection to a specific type Scope C# 2.0+ expressions Body(($TYPE$)$SELECTION$) Parameters
After expansion |