Reputation: 2519
I often find myself writing something daft like:
String.Format("{1}: {0}", reason, message);
or something similar but with far more string placeholders.
Is there an automated refactoring in ReSharper to change the order of the placeholders and the arguments? I have a tendency to mess up the mapping if I try to change the order by hand.
Obviously, the example above is trivial. What I am doing in reality is often writing something like:
String.Format("{0}.{2} = {1}.{3} AND {0}.{4} = {1}.{5} AND {6}.{7} = {1}.{8}",
table1Alias, table2Alias, col1A, col2A, col1B, col2B, table3Alias, col3C, col2C);
and thinking to myself that it would be great if I could move table3Alias up to the front next to the other aliases.
(ReSharper 7.1.3)
Upvotes: 7
Views: 1368
Reputation: 38468
Just place your cursor in table3Alias, then press Ctrl + Alt + Shift + Left/Right arrow. This changes the parameter order in a function call.
There's also an option for removing one when you press Ctrl + Shift + R
There's also a shortcut to add a format item. You may be able to do what you want with combining these. The exact functionality you ask is not implemented.
Upvotes: 1
Reputation: 2537
For C# 6+ (ReSharper 10+ / 2016+):
Use string interpolation
Convert to string.Format
Upvotes: 4