Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Encoding::GetString Method (Byte*, Int32)

.NET Framework (current version)
 

When overridden in a derived class, decodes a specified number of bytes starting at a specified address into a string.

This API is not CLS-compliant.

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

public:
[SecurityCriticalAttribute]
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(false)]
String^ GetString(
	unsigned char* bytes,
	int byteCount
)

Parameters

bytes
Type: System::Byte*

A pointer to a byte array.

byteCount
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.

Exception Condition
ArgumentNullException

bytes is a null pointer.

ArgumentOutOfRangeException

byteCount is less than zero.

DecoderFallbackException

A fallback occurred (see Character Encoding in the .NET Framework for a complete explanation)

-and-

Encoding::DecoderFallback is set to DecoderExceptionFallback.

The GetString method is designed to optimize performance when you have a native pointer to a byte array. Instead of creating a managed byte array and then decoding it, you can instead call this method without having to create any intermediate objects.

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 Decoder object returned by the GetDecoder method of a derived class.

See the Remarks section of the Encoding::GetChars reference topic for a discussion of decoding techniques and considerations.

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

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.6
Return to top
Show:
© 2017 Microsoft