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

System.Text.Encoding.GetMaxByteCount Method

Returns the maximum number of bytes required to encode the specified number of characters, regardless of the actual character values. [Edit]

public abstract int GetMaxByteCount (int charCount)

Parameters

charCount
A int containing the number of characters to encode. [Edit]

Returns

A int containing the maximum number of bytes required to encode charCount characters. [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.GetMaxByteCount(int) can be used to determine the minimum buffer size for byte arrays passed to the Encoding.GetBytes(Char[]) of the current encoding. Using this minimum buffer size ensures that no buffer overflow exceptions occur.

[Edit]

Requirements

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