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

System.Text.UTF8Encoding.GetMaxByteCount Method

Returns the maximum number of bytes required to encode the specified number of characters as a System.Text.UTF8Encoding, regardless of the actual character values.

public override int GetMaxByteCount (int charCount)

Parameters

charCount
A int that specifies the number of characters to encode as a System.Text.UTF8Encoding .

Returns

A int that specifies the maximum number of bytes required to encode charCount characters as a System.Text.UTF8Encoding .

Exceptions

TypeReason
ArgumentOutOfRangeExceptioncharCount < 0.

Remarks

Note:

This method overrides Encoding.GetMaxByteCount(int) .

This method can be used to determine an appropriate buffer size for byte arrays passed to UTF8Encoding.GetBytes(Char[], int, int, Byte[], 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