NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

CodePageEncoding.GetBytes

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;

Parameters

chars
The character array to encode.
charIndex
The starting index of the character array to encode.[RB3]
charCount
The number of characters to encode.
bytes
The byte array to encode into.
byteIndex
The starting index of the resulting encoding in the byte array.

Return Value

The number of bytes stored into the byte array.

Exceptions

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.

Remarks

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.

See Also

CodePageEncoding Class | CodePageEncoding Members | System.Globalization Namespace