Skip to main content

Format Item

In This Article

Calls the String.Formatter dialog for the String.Format format item under the caret.

StringFormatterDialog

The String.Formatter window enables visual selection of formatting options for the values you pass to the String.Format call.

Format specifiers are built automatically based on the type of the expression passed in. To bring up this window, just place the caret on the format item portion of the string (e.g., “{0}”, “{1}”, etc.), and press the CodeRush Classic key (Ctrl+` by default).

#Availability

From the context menus or via shortcuts:

  • when the caret is on a format item portion of the string passed as the first parameter to the String.Format call (e.g., “{0}”, “{1}”, etc.).

#Example

string str = string.Format("The value 0x{0} added at {1}", value, DateTime.Now);

Result:

string str = string.Format("The value 0x{0:X6} added at {1:hh:mm:ss}", value, DateTime.Now);