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