Purpose
Converts a composed string expression into a single string.Format call. The use of formatted strings increases code readability and allows you to customize value formatting.
Availability
Available when the caret is on a composed string expression or interpolated string.
Usage
Place the caret on a composed string expression.
Note
The blinking cursor shows the caret's position at which the Refactoring is available.
for (int i = 2; i < 10; i++) {
for (int j = i; j < 10; j++) {
Console.WriteLine(│i + " * " + j + " = " + i * j);
}
}
For i As Integer = 2 To 9
For j As Integer = i To 9
Console.WriteLine(│i & " * " & j & " = " & i * j)
Next j
Next i
- Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
- Select Use string.Format from the menu.
After execution, the Refactoring replaces the composed string with the string.Format method call.
for (int i = 2; i < 10; i++) {
for (int j = i; j < 10; j++) {
Console.WriteLine(string.Format("{0} * {1} = {2}", i, j, i * j));
}
}
For i As Integer = 2 To 9
For j As Integer = i To 9
Console.WriteLine(String.Format("{0} * {1} = {2}", i, j, i * j))
Next j
Next i
See Also
We are updating the DevExpress product documentation website and this page is part of our new experience. During this transition period, product documentation remains available in our previous format at documentation.devexpress.com. Learn More...