The actual number of characters written into chars.
Type Reason ArgumentException (chars.Length - charIndex) < byteCount. ArgumentNullException bytes is null.
-or-
chars is null.
ArgumentOutOfRangeException byteIndex < 0.
-or-
byteCount < 0.
-or-
(bytes.Length - byteIndex) < byteCount.
-or-
charIndex < 0.
-or-
charIndex > chars.Length.
To calculate the exact array size required by ASCIIEncoding.GetChars(Byte[], int, int, Char[], int) to store the resulting characters, the application uses ASCIIEncoding.GetCharCount(Byte[], int, int). To calculate the maximum array size, the application should use ASCIIEncoding.GetMaxCharCount(int). The ASCIIEncoding.GetCharCount(Byte[], int, int) method generally allows allocation of less memory, while the ASCIIEncoding.GetMaxCharCount(int) method generally executes faster.
Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the System.Text.Decoder or the System.Text.Encoder provided by the ASCIIEncoding.GetDecoder method or the ASCIIEncoding.GetEncoder method, respectively.
System.Text.ASCIIEncoding does not provide error detection. Any byte greater than hexadecimal 0x7F is decoded as the Unicode question mark ("?").
For security reasons, your application is recommended to use System.Text.UTF8Encoding, System.Text.UnicodeEncoding, or System.Text.UTF32Encoding and enable error detection.