roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Offer to to introduce variable in string

Open jmarolf opened this issue 9 years ago • 3 comments

Before:

Console.WriteLine("Hello Your Name");

After (applied refactoring to selection "Your Name"):

var name = "Your Name";
Console.WriteLine($"Hello {name}");

jmarolf avatar Jun 03 '16 23:06 jmarolf

Should the refactoring encourage interpolation in that case or the simpler (and more efficient) concatenation? Or provide the option to do either?

HaloFour avatar Jun 04 '16 02:06 HaloFour

Perhaps:

var name = "Your Name";
Console.WriteLine("Hello {0}", name);

jmarolf avatar Jun 04 '16 03:06 jmarolf

we would take a small community fix here.,

CyrusNajmabadi avatar Oct 18 '24 20:10 CyrusNajmabadi

Not planning on doing this.

CyrusNajmabadi avatar Sep 22 '25 11:09 CyrusNajmabadi