When overridden in a derived class, encodes a range of a character array into a byte array.
[Visual Basic] Overloads MustOverride 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 abstract int GetBytes( char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex ); [C++] public: virtual int GetBytes( __wchar_t* chars[], int charIndex, int charCount, unsigned char* bytes[], int byteIndex ) = 0; [JScript] public abstract 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 | chars or bytes is a null reference (in Visual Basic Nothing). |
ArgumentOutOfRangeException | charIndex, charCount or byteIndex is less than zero. |
ArgumentOutOfRangeException | charIndex + charCount is greater than the length of chars. |
ArgumentOutOfRangeException | byteIndex + charCount is greater than the length of bytes. |
Encodes a range of characters in a character array into a range of bytes in a byte array. An exception occurs if the byte array is not large enough to hold the complete encoding of the characters. GetByteCount can be used to determine the exact number of bytes that will be produced for a given range of characters. Alternatively, GetMaxByteCount can be used to determine the maximum number of bytes that will be produced for a given number of characters, regardless of the actual character values.
Encoding Class | Encoding Members | System.Text Namespace | Encoding.GetBytes Overload List | GetByteCount | GetMaxByteCount | GetDecoder | GetEncoder