ToArray Method

MemoryStream.ToArray Method ()

 

Writes the stream contents to a byte array, regardless of the Position property.

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

abstract ToArray : unit -> byte[]
override ToArray : unit -> byte[]

Return Value

Type: System.Byte[]

A new byte array.

This method omits unused bytes in MemoryStream from the array. To get the entire buffer, use the GetBuffer method.

This method returns a copy of the contents of the MemoryStream as a byte array. If the current instance was constructed on a provided byte array, a copy of the section of the array to which this instance has access is returned. See the MemoryStream constructor for details.

System_CAPS_noteNote

This method works when the MemoryStream is closed.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft