Determines the exact number of characters that will be produced by decoding the specified range of the specified byte array.
- bytes
- The byte array to decode.
- index
- The first index in bytes to decode.
- count
- The number of bytes to decode.
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.
Type Reason ArgumentNullException bytes is null. ArgumentOutOfRangeException index and count do not specify a valid range in bytes (i.e. (index + count) > bytes.Length).
Operation
As described above.Note to Inheritors
This method is overridden by types derived from System.Text.Encoding to return the appropriate number of bytes for the particular encoding.Usage
Use Encoding.GetCharCount(Byte[]) to determine the exact number of characters that will be produced from converting a given range of bytes. An appropriately sized buffer for that conversion can then be allocated.
Alternatively, use Encoding.GetMaxCharCount(int) to determine the maximum number of characters that will be produced for a given number of bytes, regardless of the actual byte values. A buffer of that size can then be reused for multiple conversions.
Encoding.GetCharCount(Byte[]) generally uses less memory and Encoding.GetMaxCharCount(int) generally executes faster.
Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0