Essential Types C# Book

We can append formatted string to StringBuilder with AppendFormat method.
AppendFormat works the same way with string.Format.
using System;
using System.Text;
class Sample
{
public static void Main()
{
string composite = "Name={0,-20} Account={1,15:C}";
StringBuilder sb = new StringBuilder();
sb.AppendFormat(composite, "M", 999999);
Console.WriteLine(sb);
}
}
The output:
Name=M Account= $999,999.00