If a code template has no parameters, it is applied instantly without user interactions. After the template code is inserted into your source code, you resume typing at the position specified by template developer. Templates may silently adapt to surrounding context by using template variables, but if you need to change some fields, you will be able to do so only by editing the inserted code.
In contrast, a parameterized template will guide you through all the fields that may need to be changed, and suggest reasonable choices. As you are getting acquainted with ReSharper, you will see that many of its predefined templates are parameterized. You can also study Creating and Editing Templates section to learn how to create and edit custom parameterized templates.
Parameters are template variables, which template developer made editable and optionally provided with suggested values. For example, a well-designed parameterized template for iteration over all elements of a container will suggest and allow you to choose:
- A suitable name for the loop index variable (for example, i or j).
- A list of all variables of the specified type in the current scope (for example, Arrays or Lists) as an expression for the iterated container.
- A suitable name for the assigned variable that will hold the current container element during the iteration.
- The type of elements in the iterated container.
When a parameterized template is applied, the code editor temporarily switches into the template editing mode that lets you specify or choose values for template parameters. You can either replace the parameters with your input or accept one of the suggested values that ReSharper calculates based on the input or the surrounding context.
As soon as you are in the template editing mode, the editor sets your input position at the first parameter. After you type a desired value or accept a value suggested by ReSharper, you can navigate between parameters by pressing:
- Tab or Enter to move to the input position of the next parameter.
- Shift+Tab to move the input focus to the input position of the previous parameter.
- Esc to switch off the template editing mode and move the caret to the end position defined by template developer. In this case, all parameters will be initialized with default values.