Encodes a range of an array of characters into an array of bytes and returns the number bytes stored in the array.
[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 |
---|---|
ArgumentException | The chars or bytes arguments are null. |
ArgumentException | The charIndex and charCount arguments do not denote a valid range in the character array. |
ArgumentException | The byteIndex or charIndex arguments are not a valid index.[RB4] |
ArgumentException | The byteIndex argument is less than 0. |
ArgumentException | The byteIndex argument is greater than the length of the byte array. |
ArgumentException | The bytes argument is not large enough to hold the encoding of the characters. |
System.Globalization.Encoding.BufferOverflow | The byteIndex argument is equal to the length of the byte array. |
System.Globalization.Encoding.BufferOverflow | No bytes have been stored into the byte array. |
This method overrides Encoding.GetBytes.
The GetByteCount 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.
CodePageEncoding Class | CodePageEncoding Members | System.Globalization Namespace