This documentation is archived and is not being maintained.
Encoding.GetBytes Method (String, Int32, Int32, Byte[], Int32)
.NET Framework 1.1
Encodes the specified range of a String into the specified range of a byte array.
[Visual Basic] Overloads Public Overridable Function GetBytes( _ ByVal s As String, _ ByVal charIndex As Integer, _ ByVal charCount As Integer, _ ByVal bytes() As Byte, _ ByVal byteIndex As Integer _ ) As Integer [C#] public virtual int GetBytes( string s, int charIndex, int charCount, byte[] bytes, int byteIndex ); [C++] public: virtual int GetBytes( String* s, int charIndex, int charCount, unsigned char bytes __gc[], int byteIndex ); [JScript] public function GetBytes( s : String, charIndex : int, charCount : int, bytes : Byte[], byteIndex : int ) : int;
Parameters
- s
- A String to encode.
- charIndex
- The first index of s from which to encode.
- charCount
- The number of characters of s to encode.
- bytes
- The byte array to encode into.
- byteIndex
- The first index of bytes to encode into.
Return Value
The number of encoded bytes in array bytes.
Exceptions
Exception Type | Condition |
---|---|
ArgumentException | bytes does not contain sufficient space to store the encoded characters. |
ArgumentNullException | s or bytes is a null reference (Nothing in Visual Basic). |
ArgumentOutOfRangeException | charIndex, charCount, or byteIndex is less than zero.
-or- charIndex and charCount do not specify a valid range in s (that is, (charIndex + charCount) is greater than the length of s). |
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard
See Also
Encoding Class | Encoding Members | System.Text Namespace | Encoding.GetBytes Overload List
Show: