Version

GetBytes Method

When overridden in a derived class, encodes a set of characters from the specified character array into the specified byte array.
Syntax
'Declaration
 
Function GetBytes( _
   ByVal chars() As Char, _
   ByVal charIndex As Integer, _
   ByVal charCount As Integer, _
   ByVal bytes() As Byte, _
   ByVal byteIndex As Integer _
) As Integer
int GetBytes( 
   char[] chars,
   int charIndex,
   int charCount,
   byte[] bytes,
   int byteIndex
)

Parameters

chars
The character array containing the set of characters to encode.
charIndex
The zero-based Index of the first character to encode.
charCount
The number of characters to encode.
bytes
The byte array to contain the resulting sequence of bytes.
byteIndex
The zero-based Index at which to start writing the resulting sequence of bytes.

Return Value

The actual number of bytes written into bytes.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionchars is null.-or- bytes is null.
System.ArgumentOutOfRangeExceptioncharIndex or charCount or byteIndex is less than zero.-or- charIndex and charCount do not denote a valid range in chars.-or- byteIndex is not a valid Index in bytes.
System.ArgumentExceptionbytes does not have enough capacity from byteIndex to the End of the array to accommodate the resulting bytes.
System.Text.EncoderFallbackExceptionA fallback occurred (see Understanding Encodings for complete explanation).
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also