Mono Class Library: System.Text.UTF8Encoding Overview | Members

System.Text.UTF8Encoding.GetMaxCharCount Method

Returns the maximum number of characters produced by decoding the specified number of bytes as a System.Text.UTF8Encoding, regardless of the actual byte values.

public override int GetMaxCharCount (int byteCount)

Parameters

byteCount
A int that specifies the number of bytes to decode as a System.Text.UTF8Encoding .

Returns

A int that specifies the maximum number of characters produced by decoding byteCount bytes as a System.Text.UTF8Encoding .

Exceptions

TypeReason
ArgumentOutOfRangeExceptionbyteCount < 0.

Remarks

Note:

This method overrides Encoding.GetMaxCharCount(int) .

This method can be used to determine an appropriate minimum buffer size for character arrays passed to UTF8Encoding.GetChars(Byte[], int, int, Char[], int) . Using this minimum buffer size can help ensure that no buffer overflow exceptions will occur.

Requirements

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0