Calculates the number of bytes produced by encoding a set of characters from the specified character array.
The number of bytes produced by encoding the specified characters.
Type Reason ArgumentNullException chars is null. ArgumentOutOfRangeException index < 0.
-or-
count < 0.
-or-
index and count do not specify a valid range in chars (i.e. ( index + count - 1) > chars.Length).
To calculate the exact array size required by ASCIIEncoding.GetBytes(string, int, int, Byte[], int) to store the resulting bytes, the application uses ASCIIEncoding.GetByteCount(Char[], int, int). To calculate the maximum array size, the application should use ASCIIEncoding.GetMaxByteCount(int). The ASCIIEncoding.GetByteCount(Char[], int, int) method generally allows allocation of less memory, while the ASCIIEncoding.GetMaxByteCount(int) method generally executes faster.