Appends the specified string to the current instance, with the format specifications in that string being replaced with the appropriately formatted string value of the specified object.
The current instance after the operation has occurred.
Type Reason ArgumentNullException format is a null reference. FormatException format is invalid.
This method appends the formatted copy of the specified string to the current instance.
Note: This version of StringBuilder.AppendFormat(string, object) is equivalent to StringBuilder.AppendFormat(string, object)( null , format, new Object[] {arg0} ). For more information on the format specification, see the string class overview.
C# Example
using System; using System.Text; public class StringBuilderTest { public static void Main() { StringBuilder sb = new StringBuilder("The high "); Console.WriteLine( sb.AppendFormat("temperature today was {0, 6}.", 88) ); } }The output is
Example
The high temperature today was 88.
Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0