When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters from the specified character array. A parameter indicates whether to clear the internal state of the encoder after the calculation.
The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
Type Reason ArgumentNullException chars is null. ArgumentOutOfRangeException Return value is greater than int.MaxValue.
-or-
index < 0.
-or-
count < 0.
-or-
index and count do not specify a valid range in chars (i.e. (index + count) > chars.Length).
This method does not affect the state of the encoder.
To calculate the exact array size that Encoder.GetBytes(Char[], int, int, Byte[], int, bool) requires to store the resulting bytes, the application should use Encoder.GetByteCount(Char[], int, 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.