GetString Method

UTF8Encoding.GetString Method

Decodes a range of bytes from a byte array into a string.

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

public override string GetString(
	byte[] bytes,
	int index,
	int count


Type: System.Byte[]
The byte array containing the sequence of bytes to decode.
Type: System.Int32
The zero-based index of the first byte to decode.
Type: System.Int32
The number of bytes to decode.

Return Value

Type: System.String
A string that contains the results of decoding the specified sequence of bytes.


bytes is null.


index or count is less than zero.


index and count do not denote a valid range in bytes.


Error detection is enabled, and bytes contains an invalid sequence of bytes.


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

With error detection, an invalid sequence causes this method to throw a ArgumentException. Without error detection, invalid sequences are ignored, and no exception is thrown.

Data to be converted, such as data read from a stream, might be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application uses the Decoder or the Encoder provided by the GetDecoder method or the GetEncoder method, respectively.


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

© 2015 Microsoft