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

System.Text.Decoder.GetCharCount Method

Determines the exact number of characters that will be produced by decoding the specified range of the specified array of bytes.

public abstract int GetCharCount (byte[] bytes, int index, int count)

Parameters

bytes
A byte array to decode.
index
A int that specifies the first index in bytes to decode.
count
A int that specifies the number elements in bytes to decode.

Returns

A int containing the number of characters the next call to Decoder.GetChars(Byte[], int, int, Char[], int) will produce if presented with the specified range of bytes .

Note: This value takes into account the state in which the current instance was left following the last call to Decoder.GetChars(Byte[], int, int, Char[], int). This contrasts with Encoding.GetChars(Byte[]), which does not maintain state information across subsequent calls.

Exceptions

TypeReason
ArgumentNullExceptionbytes is null .
ArgumentOutOfRangeException

index < 0.

-or-

count < 0.

-or-

index and count do not specify a valid range in bytes (i.e. (index + count) > bytes.Length).

Remarks

Operation
As described above.

Note to Inheritors
Override this method to return the appropriate value for a particular encoding.

Usage
Use this method to determine the appropriate size of a buffer to contain the decoded values.

Requirements

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