Predefined Live Templates

ReSharper provides a number of predefined Live Templates covering some of the most commonly used standard code fragments. This section describes each of these templates in detail. For details on how to invoke Live Templates, see Using Live Templates.

All predefined templates and corresponding abbreviations are described below, divided into several groups.

Plain

Templates in this group are very simple: they expand to short static C# code fragments. Example:

  1. To declare a constant with public const int, type pci:

     

  2. Press Tab. The following code fragment will expand with the caret positioned at the next reasonable input point:

     

 

Abbreviation Full code after expansion Details
pci

public const int

pcs public const string
psr public static readonly
thr throw new
asrt System.Diagnostics.Debug.Assert(); After expansion the caret is positioned between the parentheses so that you can start writing the assertion.
psvm public static void Main(string[] args)
{

}
After expansion the caret is positioned between the braces so that you can start writing the function body.


 

Iterations

Templates in this group are used for iterating over various containers. Since these templates are parametrized, you will need to fill in some parameters (variables) after the template is expanded. These input fields routinely include:

To help you complete the necessary input fields, ReSharper will suggest a list of choices. They include names for variables, instances of arrays, lists, etc which are available in the scope and so on. Please see this pictorial for a graphic illustration of the process.

Click a template abbreviation in the list below to go to its description: