C# UnicodeEncoding GetCharCount(Byte[])

Description

UnicodeEncoding GetCharCount(Byte[]) When overridden in a derived class, calculates the number of characters produced by decoding all the bytes in the specified byte array.

Syntax

UnicodeEncoding.GetCharCount(Byte[]) has the following syntax.


public virtual int GetCharCount(
  byte[] bytes
)

Parameters

UnicodeEncoding.GetCharCount(Byte[]) has the following parameters.

  • bytes - The byte array containing the sequence of bytes to decode.

Returns

UnicodeEncoding.GetCharCount(Byte[]) method returns The number of characters produced by decoding the specified sequence of bytes.

Example


/*from   w ww  .  j a v  a  2  s .  c o  m*/
using System;
using System.Text;

public class SamplesEncoding
{

    public static void Main()
    {
        Encoding enc = Encoding.GetEncoding("utf-32");


        int iCC = enc.GetCharCount(new byte[]{1,2,3});
        Console.Write(" {0,-3}", iCC);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding