RecyclableMemoryStream.ToArray method
October 6, 2021 · View on GitHub
Returns a new array with a copy of the buffer's contents. You should almost certainly be using GetBuffer combined with the Length to access the bytes in this stream. Calling ToArray will destroy the benefits of pooled buffers, but it is included for the sake of completeness.
[Obsolete("This method has degraded performance vs. GetBuffer and should be avoided.")]
public override byte[] ToArray()
Exceptions
| exception | condition |
|---|---|
| ObjectDisposedException | Object has been disposed. |
| NotSupportedException | The current RecyclableMemoryStreamManagerobject disallows ToArray calls. |
| OutOfMemoryException | The length of the stream is too long for a contiguous array. |
See Also
- class RecyclableMemoryStream
- namespace Microsoft.IO