Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use this procedure to perform the Promote Local Variable to Parameter refactoring operation. For more information, see Promote Local Variable to Parameter.
To promote a local variable to parameter
Create a console application, and set it up as described in the following example. For more information, see How to: Create a C# Console Application.
Place the pointer next to i at its definition in MethodB.
From the Refactor menu, select Promote Local Variable to Parameter.
You can also type the keyboard shortcut CTRL+R, P to complete the refactoring operation.
You can also right-click the pointer, point to Refactor on the context menu, and then click Promote Local Variable to Parameter to complete the refactoring operation.
The MethodB should now have a parameter int i, and the call ProtoA.MethodB will now pass zero as a value.
Example
To set up this example, create a console application named PromoteLocal, and then add the following code after the Program class in the PromoteLocal namespace. For more information, see How to: Create a C# Console Application.
class ProtoA
{
public static void MethodB()
{
// Invoke on 'i'
int i = 0;
}
}
class ProtoC
{
void MethodD()
{
ProtoA.MethodB();
}
}