Introduce Format Item


Extracts a part of the formatted string into a format item. This Code Provider is especially useful if you used to construct a string first and then replace its parts with the variables.


Available when a part of the formatted string is selected.


  1. Select a part of the formatted string.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Introduce Format Item from the menu.

After execution, the Code Provider creates a string.Format call with the selected part extracted into a format item. If the string is already a format string, the selected part will be added as a new format item to the existing composite formatting method.

string debugString = string.Format("a: {0}\tb: 2.34\tc: 3.456;", "1.2");
See Also