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. A parameter indicates whether to clear the internal state of the decoder after the calculation.

Syntax

[System.Runtime.InteropServices.ComVisible(false)]
public virtual int GetCharCount (byte[] bytes, int index, int count, bool flush)

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.
flush
true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.

Returns

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

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, bool) requires to store the resulting characters, the application should use Decoder.GetCharCount(Byte[], int, int, bool).

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: 2.0.0.0, 4.0.0.0
Since: .NET 2.0