C# UnicodeEncoding GetChars(Byte[], Int32, Int32)

Description

UnicodeEncoding GetChars(Byte[], Int32, Int32) When overridden in a derived class, decodes a sequence of bytes from the specified byte array into a set of characters.

Syntax

UnicodeEncoding.GetChars(Byte[], Int32, Int32) has the following syntax.


public virtual char[] GetChars(
  byte[] bytes,//from w w  w .  j  a v  a2 s .  c o m
  int index,
  int count
)

Parameters

UnicodeEncoding.GetChars(Byte[], Int32, Int32) has the following parameters.

  • bytes - The byte array containing the sequence of bytes to decode.
  • index - The index of the first byte to decode.
  • count - The number of bytes to decode.

Returns

UnicodeEncoding.GetChars(Byte[], Int32, Int32) method returns

Example


using System;//from  w w  w.ja v  a2  s .c om
using System.Text;

public class SamplesEncoding
{

    public static void Main()
    {
        Encoding enc = Encoding.GetEncoding("utf-32");
        char[] chars = enc.GetChars(new byte[]{66,68,67,}, 0, 3);

        Console.WriteLine(chars);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding