System.Text.Encoder.GetByteCount Method

When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer. A parameter indicates whether to clear the internal state of the encoder after the calculation.

Syntax

[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public virtual int GetByteCount (char* chars, int count, bool flush)

Parameters

chars
A pointer to the first character to encode.
count
The number of characters to encode.
flush
true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.

Returns

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

Remarks

This method does not affect the state of the encoder.

To calculate the exact array size that Encoder.GetBytes(Char*, int, Byte*, int, bool) requires to store the resulting bytes, the application should use Encoder.GetByteCount(Char*, int, bool).

If GetBytes is called with flush set to false, the encoder stores trailing characters at the end of the data block in an internal buffer and uses them in the next encoding operation. The application should call GetByteCount on a block of data immediately before calling GetBytes on the same block, so that any trailing characters 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