Encoding::GetChars Method (array<Byte>, Int32, Int32, array<Char>, Int32)
When overridden in a derived class, decodes a sequence of bytes from the specified byte array into the specified character array.
Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Parameters
- bytes
- Type: array<System::Byte>
The byte array containing the sequence of bytes to decode.
- byteIndex
- Type: System::Int32
The zero-based index of the first byte to decode.
- byteCount
- Type: System::Int32
The number of bytes to decode.
- chars
- Type: array<System::Char>
The character array to contain the resulting set of characters.
- charIndex
- Type: System::Int32
The zero-based index at which to start writing the resulting set of characters.
| Exception | Condition |
|---|---|
| ArgumentNullException | bytes is nullptr. -or- chars is nullptr. |
| ArgumentOutOfRangeException | byteIndex or byteCount or charIndex is less than zero. -or- byteindex and byteCount do not denote a valid range in bytes. -or- charIndex is not a valid index in chars. |
| ArgumentException | chars does not have enough capacity from charIndex to the end of the array to accommodate the resulting characters. |
| DecoderFallbackException | A fallback occurred (see Understanding Encodings for complete explanation). |
To calculate the exact array size required by GetChars to store the resulting characters, the application should use GetCharCount. To calculate the maximum array size, the application should use GetMaxCharCount. The GetCharCount method generally allocates less memory, while the GetMaxCharCount method generally executes faster.
If the data to be converted is available only in sequential blocks (such as data read from a stream) or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the Decoder or the Encoder provided by the GetDecoder method or the GetEncoder method, respectively, of a derived class.
For a discussion of programming considerations for use of this method, see the Encoding class description.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.