MemoryStream.ToArray Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Writes the stream contents to a byte array, regardless of the Position property.
public:
virtual cli::array <System::Byte> ^ ToArray();
public virtual byte[] ToArray ();
abstract member ToArray : unit -> byte[]
override this.ToArray : unit -> byte[]
Public Overridable Function ToArray () As Byte()
Returns
A new byte array.
Remarks
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.
Note
This method works when the MemoryStream is closed.