Determines the exact number of characters that will be produced by decoding the specified byte array.
- bytes
- The byte array to decode.
A int containing the number of characters produced by decoding bytes.
Type Reason ArgumentNullException bytes is null.
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 byte array. 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