Declare Parameter
- 2 minutes to read
Purpose
Inserts an undeclared identifier to the method parameters list. Use this Code Provider inside a method to add the new parameter from the place where it was referenced.
NOTE
Declare Parameter is a cascading Code Provider. That means that the Code Provider affects all method calls and method declarations in interfaces, base and descendant classes.
Availability
Available when the caret is on an undeclared identifier name.
Usage
Place the caret on the undeclared identifier.
NOTE
The blinking cursor shows the caret's position at which the Code Provider is available.
Hit Ctrl + . or Ctrl + ~ to invoke the Code Actions Menu.
Use the mouse to select Declare | Declare Parameter from the menu and press Enter.
After execution, the Code Provider adds the new method parameter named after the variable and adds a dummy value of the corresponding type to each method call.
public static double ConvertToUSD(double amount, Currency source) {
return amount / GetCurrencyRate(source);
}
static void Main(string[] args) {
double price = ConvertToUSD(10, Currency.USD); // The first enum item was used
}