Convert to String Interpolation
Purpose
Converts a formatted string into string interpolation. Interpolated strings are much easier to read than formatted strings.
Availability
Available when the cursor is on a composed string expression (as shown in the code below) or on the call of one of the following methods, assuming the method argument contains formatted string.
- String.Format
- Debug.Print
- Console.Write
- Console.WriteLine
- StringBuilder.AppendFormat
Usage
Place the caret on a composed string expression.
Note
The blinking cursor shows the caret’s position at which the Refactoring is available.
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
- Select Convert to String Interpolation from the menu.
After execution, Refactoring replaces the composed string to the interpolated string.
Note
This feature is available as a part of Code Cleanup.
See Also