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

System.Text.UnicodeEncoding.GetMaxByteCount Method

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

public override int GetMaxByteCount (int charCount)

Parameters

charCount
A int whose value represents a number of characters to encode as Unicode-encoded characters. [Edit]

Returns

A int containing the maximum number of bytes required to encode charCount characters as Unicode-encoded characters. [Edit]

Exceptions

TypeReason
ArgumentOutOfRangeExceptioncharCount < 0. [Edit]

Remarks

Note:

This method overrides Encoding.GetMaxByteCount(int).

Use this method to determine an appropriate minimum buffer size for byte arrays passed to UnicodeEncoding.GetBytes(Char[], int, int, Byte[], int) or Encoder.GetBytes(Char[], int, int, Byte[], int, bool) for the current instance. Using this minimum buffer size can help ensure that buffer overflow exceptions do not occur.

[Edit]

Requirements

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