System.Text.Encoding.GetString Method

When overridden in a derived class, decodes all the bytes in the specified byte array into a string.

Syntax

public virtual string GetString (byte[] bytes)

Parameters

bytes
The byte array containing the sequence of bytes to decode.

Returns

A string that contains the results of decoding the specified sequence of bytes.

Exceptions

TypeReason
ArgumentNullException bytes is null.

Remarks

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, you should use the System.Text.Decoder object returned by the Encoding.GetDecoder method of a derived class.

See the Remarks section of the Encoding.GetChars(Byte[]) reference topic for a discussion of decoding techniques and considerations.

Note that the precise behavior of the Encoding.GetString(Byte[]) method for a particular System.Text.Encoding implementation depends on the fallback strategy defined for that System.Text.Encoding object. For more information, see the "Choosing a Fallback Strategy" section of the Character Encoding in the .NET Framework topic.

Requirements

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0