Composite format strings combines variable substitution with format strings.
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
string composite = "Credit={0:C}";
Console.WriteLine(string.Format(composite, 500)); // Credit=$500.00
}
}
The output:
Credit=$500.00
The Console class overloads its Write and WriteLine methods to accept composite format strings.
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
Console.WriteLine("Credit={0:C}", 500); // Credit=$500.00
}
}
The output:
Credit=$500.00