C# UnicodeEncoding GetMaxCharCount

Description

UnicodeEncoding GetMaxCharCount Calculates the maximum number of characters produced by decoding the specified number of bytes.

Syntax

UnicodeEncoding.GetMaxCharCount has the following syntax.


public override int GetMaxCharCount(
  int byteCount
)

Parameters

UnicodeEncoding.GetMaxCharCount has the following parameters.

  • byteCount - The number of bytes to decode.

Returns

UnicodeEncoding.GetMaxCharCount method returns The maximum number of characters produced by decoding the specified number of bytes.

Example


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

class UnicodeEncodingExample {
    public static void Main() {
        UnicodeEncoding Unicode = new UnicodeEncoding();
        int byteCount = 8;
        int maxCharCount = Unicode.GetMaxCharCount(byteCount);
        Console.WriteLine(
            "Maximum of {0} characters needed to decode {1} bytes.",
            maxCharCount,
            byteCount
        );
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding