Visual Studio Tip – Named Parameters in Generated Methods

Really quick tip that I found recently while refactoring some old code.

If your using Generate Method (Ctrl + .) in Visual Studio, the method youre generating uses the same names as the local variables for parameter names:

Generate Method without Named Parameters
Generate Method without Named Parameters

I dont know about you, but I then have to spent more than a zero time tidying it up to be more meaningful. Thankfully named parameters can take care of that for you:

Generate Method without Named Parameters
Generate Method without Named Parameters

Seems to work for constructors and other refactors too.

Maybe its common knowledge, but it pleased me, so by putting it here I can remind myself in a couple years weeks time when I forget.


Comments Section