C# StringBuilder Append(Char)

Description

StringBuilder Append(Char) Appends the string representation of a specified Unicode character to this instance.

Syntax

StringBuilder.Append(Char) has the following syntax.


public StringBuilder Append(
  char value
)

Parameters

StringBuilder.Append(Char) has the following parameters.

  • value - The Unicode character to append.

Returns

StringBuilder.Append(Char) method returns A reference to this instance after the append operation has completed.

Example

Appends the string representation of a specified Unicode character to this instance.


using System;//from ww  w  .j  a  v  a 2 s.c  om
using System.Text;

class Sample 
{
    public static void Main() 
    {
        string str = "Characters in a string.";
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        foreach (var ch in str)
           sb.Append(" '").Append(ch).Append("' ");
        Console.WriteLine("  {0}", sb);

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding