#973 – Format Items in Composite Format Strings Can Be in Any Order

A composite format string contains some combination of actual text and format items that will be substituted with values of corresponding placeholders at run-time.

For example:

            string name = "Sean";
            int age = 49;

            Console.WriteLine(string.Format("{0} is {1} yrs old. {0} is old.", name, age));


A format item is indicated by a 0-based index within a pair of braces. Notice that you can have multiple format items that refer to the same placeholder.

You can also include the format items in any order.  At run-time, each format item is evaluated and the appropriate value is substituted.

            Console.WriteLine(string.Format("Age: {1}, Name: {0}.  {1} {1} {1}..", name, age));