Encodes a range of an array of characters into a array of bytes.
[Visual Basic] Overrides Public Function GetBytes( _ ByVal chars() As Char, _ ByVal charIndex As Integer, _ ByVal charCount As Integer, _ ByVal bytes() As Byte, _ ByVal byteIndex As Integer _ ) As Integer [C#] public override int GetBytes( char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex ); [C++] public: override int GetBytes( __wchar_t* chars[], int charIndex, int charCount, unsigned char* bytes[], int byteIndex ); [JScript] public override function GetBytes( chars : Char[], charIndex : int, charCount : int, bytes : Byte[], byteIndex : int ) : int;
The number of bytes stored into the byte array.
Exception Type | Condition |
---|---|
ArgumentNullException | If chars or bytes is a null reference (in Visual Basic Nothing). |
ArgumentOutOfRangeException | If charIndex, charCount or byteIndex is less than zero. |
ArgumentOutOfRangeException | If charIndex + charCount is greater than the length of chars. |
ArgumentOutOfRangeException | If byteIndex + charCount is greater than the length of bytes. |
This method overrides GetBytes.
This method can be used to determine the exact number of bytes that will be produced for a specified range of characters. Alternatively, the GetMaxByteCount method can be used to determine the maximum number of bytes that will be produced for a specified number of characters, regardless of the actual character values.
ASCIIEncoding Class | ASCIIEncoding Members | System.Text Namespace