Appends a composite format string
using System;
using System.Text;
using System.Globalization;
class Sample
{
static StringBuilder sb = new StringBuilder();
public static void Main()
{
int var1 = 111;
float var2 = 2.22F;
string var3 = "abcd";
object[] var4 = {3, 4.4, 'X'};
Console.WriteLine("StringBuilder.AppendFormat method:");
sb.AppendFormat("1) {0}", var1);
Console.WriteLine(sb);
sb.AppendFormat("2) {0}, {1}", var1, var2);
Console.WriteLine(sb);
sb.AppendFormat("3) {0}, {1}, {2}", var1, var2, var3);
Console.WriteLine(sb);
sb.AppendFormat("4) {0}, {1}, {2}", var4);
Console.WriteLine(sb);
CultureInfo ci = new CultureInfo("es-ES", true);
sb.AppendFormat(ci, "5) {0}", var2);
Console.WriteLine(sb);
}
}
Related examples in the same category