Mega Code Archive

 
Categories / C# / Development Class
 

Appends various data to StringBuilder

using System; using System.Text; class Sample  {     public static void Main()      {         Object   obj       = 0;              bool        xBool     = true;         byte        xByte     = 1;         short       xInt16    = 2;         int         xInt32    = 3;         long        xInt64    = 4;         Decimal     xDecimal  = 5;         float       xSingle   = 6.6F;         double      xDouble   = 7.7;              ushort      xUInt16   = 8;         uint        xUInt32   = 9;         ulong       xUInt64   = 10;         sbyte       xSByte    = -11;              StringBuilder sb = new StringBuilder();              sb = sb.Append(xBool);         sb = sb.Append(obj).Append(xByte);         sb = sb.Append(xInt16);         sb = sb.Append(xInt32);         sb = sb.Append(xInt64);         sb = sb.Append(xDecimal);         sb = sb.Append(xSingle).Append(xDouble);              sb = sb.Append(xUInt16);         sb = sb.Append(xUInt32).Append(xUInt64);         sb = sb.Append(xSByte);              String str = sb.ToString();         Console.WriteLine("The appended string is:");         Console.WriteLine(str);     } }