UTF8Encoding.GetString Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
<ComVisibleAttribute(False)> _
Public Overrides Function GetString ( _
    bytes As Byte(), _
    index As Integer, _
    count As Integer _
) As String
[SecuritySafeCriticalAttribute]
[ComVisibleAttribute(false)]
public override string GetString(
    byte[] bytes,
    int index,
    int count
)

Parameters

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

Return Value

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

Exceptions

Exception Condition
ArgumentNullException

bytes is nulla null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

index or count is less than zero.

-or-

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

ArgumentException

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

DecoderFallbackException

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

Remarks

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.

Version Information

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

Platforms

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