The format string supplied to formatting methods (such as string.Format()) must be formatted correctly, otherwise the exception System.FormatException will be thrown.

Change the format string so that it is correctly formatted. Ensure that each format item adheres to the syntax:

{index[,alignment][:formatString]}

When literals { or } are required, replace them with {{ and }}, respectively, or supply them as arguments.

In this example, a format string uses both literals { and }, but the literals are not properly escaped.

In the revised example, the literals are properly escaped.

  • MSDN: String.Format Method.
  • Microsoft: Composite Formatting.