Encoding::GetBytes Method (array<Char>)

When overridden in a derived class, encodes all the characters in the specified character array into a sequence of bytes.

Namespace:  System.Text
Assembly:  mscorlib (in mscorlib.dll)

No code example is currently available or this language may not be supported.

Parameters

chars
Type: array<System::Char>
The character array containing the characters to encode.

Return Value

Type: array<System::Byte>
A byte array containing the results of encoding the specified set of characters.

ExceptionCondition
ArgumentNullException

chars is nullptr.

EncoderFallbackException

A fallback occurred (see Understanding Encodings for complete explanation).

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.

The following code example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes.

No code example is currently available or this language may not be supported.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: