MemoryStream.TryGetBuffer(ArraySegment<Byte>) 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.
Returns the array of unsigned bytes from which this stream was created. The return value indicates whether the conversion succeeded.
public:
virtual bool TryGetBuffer([Runtime::InteropServices::Out] ArraySegment<System::Byte> % buffer);
public virtual bool TryGetBuffer (out ArraySegment<byte> buffer);
abstract member TryGetBuffer : ArraySegment -> bool
override this.TryGetBuffer : ArraySegment -> bool
Public Overridable Function TryGetBuffer (ByRef buffer As ArraySegment(Of Byte)) As Boolean
Parameters
- buffer
- ArraySegment<Byte>
When this method returns true
, the byte array segment from which this stream was created; when this method returns false
, this parameter is set to default
.
Returns
true
if the buffer is exposable; otherwise, false
.
Remarks
This method returns true
when the underlying buffer is marked as exposable, which happens when the current MemoryStream
instance is created with:
- MemoryStream().
- MemoryStream(Int32).
- MemoryStream(Byte[], Int32, Int32, Boolean, Boolean) with the parameter
publiclyVisible
set totrue
.
The underlying buffer will not be exposed if the current MemoryStream
instance is created with:
- MemoryStream(Byte[], Boolean)
- MemoryStream(Byte[], Int32, Int32, Boolean, Boolean) with the parameter
publiclyVisible
set tofalse
.
Note
This method works when the memory stream is closed.