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!

Encoding.GetChars (Byte[], Int32, Int32, Char[], Int32)

When overridden in a derived class, decodes a range of bytes in a byte array into a range of characters in a character array.

[Visual Basic]
Overloads MustOverride Public Function GetChars( _
   ByVal bytes() As Byte, _
   ByVal byteIndex As Integer, _
   ByVal byteCount As Integer, _
   ByVal chars() As Char, _
   ByVal charIndex As Integer _
) As Integer
[C#]
public abstract int GetChars(
   byte[] bytes,
   int byteIndex,
   int byteCount,
   char[] chars,
   int charIndex
);
[C++]
public: virtual int GetChars(
   unsigned char* bytes[],
   int byteIndex,
   int byteCount,
   __wchar_t* chars[],
   int charIndex
) = 0;
[JScript]
public abstract function GetChars(
   bytes : Byte[],
   byteIndex : int,
   byteCount : int,
   chars : Char[],
   charIndex : int
) : int;

Parameters

bytes
The byte array to decode.
byteIndex
The starting index of the byte array to decode.
byteCount
The number of bytes to decode.
chars
The character array to decode into.
charIndex
The starting index of the resulting decoding in the character array.

Return Value

The number of characters stored into the character array.

Exceptions

Exception Type Condition
ArgumentNullException If bytes or chars is a null reference (in Visual Basic Nothing).
ArgumentOutOfRangeException If byteIndex, byteCount or charIndex is less than zero.
ArgumentOutOfRangeException If byteIndex + byteCount is greater than the length of bytes.
ArgumentOutOfRangeException If charIndex + byteCount is greater than the length of chars.

Remarks

The GetChars method maintains no state between conversions. The method is intended for conversions of complete blocks of bytes and characters in one operation. The GetChars method requires the caller to provide the destination buffer and ensure that the buffer is large enough to hold the entire result of the conversion. When using this method directly on an Encoding object or on an associated Decoder or Encoder, an application can use GetCharCount or GetMaxCharCount to allocate destination buffers.

You can use this method to determine the exact number of characters that will be produced for a given range of bytes. Alternatively, the GetMaxCharCount method can be used to determine the maximum number of characters that will be produced for a given number of bytes, regardless of the actual byte values.

See Also

Encoding Class | Encoding Members | System.Text Namespace | Encoding.GetChars Overload List | GetCharCount | GetMaxCharCount