Visual Studio 2015 brings two new refactorings: Introduce Local Variable, and Inline Temporary Variable.
Inline Temporary Variable is actually the exact opposite of Introduce Local Variable. At times you’ll be using a variable for something so simple that it actually clutters the code. For example:
var firstArgument = args; Console.WriteLine(firstArgument);
We can get rid of the firstArgument variable by using the Inline Temporary Variable refactoring.
To do this, we first need to select the firstArgument variable on the first line (where it is being declared), and then press Ctrl+. (Control Dot) or select “Quick Actions…” from the context menu after right-clicking the selection. This brings up the refactorings menu, from which we can select the refactoring we want:
After selecting the Inline Temporary Variable refactoring from the menu, the code gets cleaned up pretty nicely: