System.Text.Decoder.GetCharCount Method

When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.

Syntax

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

Parameters

bytes
The byte array containing the sequence of bytes to decode.
index
The index of the first byte to decode.
count
The number of bytes to decode.

Returns

The number of characters produced by decoding the specified sequence of bytes and any bytes in the internal buffer.

Exceptions

TypeReason
ArgumentNullException bytes 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

This method does not affect the state of the decoder.

To calculate the exact array size that Decoder.GetChars(Byte[], int, int, Char[], int) requires to store the resulting characters, the application should use Decoder.GetCharCount(Byte[], int, int).

If GetChars is called with flush set to false, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call GetCharCount on a block of data immediately before calling GetChars on the same block, so that any trailing bytes from the previous block are included in the calculation.

Requirements

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