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

System.Text.Encoding.GetMaxCharCount Method

Returns the maximum number of characters produced by decoding the specified number of bytes, regardless of the actual byte values. [Edit]

public abstract int GetMaxCharCount (int byteCount)

Parameters

byteCount
A int containing the number of bytes to decode. [Edit]

Returns

A int containing the maximum number of characters that would be produced by decoding byteCount bytes. [Edit]

Remarks

Operation
As described above.

Note to Inheritors
This method is overridden by types derived from System.Text.Encoding to return the appropriate number of bytes for the particular encoding.

Usage
Encoding.GetMaxCharCount(int) can be used to determine the minimum buffer size for byte arrays passed to the Encoding.GetChars(Byte[]) of the current encoding. Using this minimum buffer size ensures that no buffer overflow exceptions will occur.

[Edit]

Requirements

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