Inserts various data types : StringBuilder « Development Class « C# / C Sharp

Inserts various data types

using System;
using System.Text;

class Sample 
    static StringBuilder sb;

    public static void Main() 
        string      xyz       = "xyz";
        char[]      abc       = {'a', 'b', 'c'};
        char        star      = '*';
        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;
        sb = new StringBuilder();
        sb.Insert(3, xyz, 2);
        sb.Insert(3, xyz);
        sb.Insert(3, star);
        sb.Insert(3, abc);
        sb.Insert(3, abc, 1, 2);
        sb.Insert(3, xBool);     // True
        sb.Insert(3, obj);       // 0
        sb.Insert(3, xByte);     // 1
        sb.Insert(3, xInt16);    // 2
        sb.Insert(3, xInt32);    // 3
        sb.Insert(3, xInt64);    // 4
        sb.Insert(3, xDecimal);  // 5
        sb.Insert(3, xSingle);   // 6.6
        sb.Insert(3, xDouble);   // 7.7
        sb.Insert(3, xUInt16);   // 8
        sb.Insert(3, xUInt32);   // 9
        sb.Insert(3, xUInt64);   // 10
        sb.Insert(3, xSByte);    // -11



Related examples in the same category

1.Create a StringBuilder which hold 100 characters.
2.Length and Indexer
3.Use StringBuilder to reverse a string
4.using the StringBuilder methods Replace, Insert, Append, AppendFormat, and Remove:
5.String ConcatenationString Concatenation
6.illustrates reading and writing string dataillustrates reading and writing string data
7.Replace char in a StringBuilder object
8.Replace Char with String
9.Represents a mutable string of characters.
10.Create StringBuilder class using the specified capacity.
11.Create StringBuilder class that starts with a specified capacity and can grow to a specified maximum.
12.Create a StringBuilder class using the specified string.
13.Create StringBuilder class using the specified string and capacity.
14.Create StringBuilder class from the specified substring and capacity.
15.Appends various data to StringBuilder
16.Appends a composite format string
17.Appends the default line terminator to the end of the current StringBuilder object.
18.Gets or sets the maximum number of characters that can be contained
19.Removes all characters from the current StringBuilder instance.
20.Copies characters to a destination Char array.
21.Removes the specified range of characters from this instance.
22.Replaces all occurrences of a specified character in this instance with another specified character.