class MemoryStream
Creates a stream whose backing store is memory.
public MemoryStream( byte[] buffer )
Initializes a new non-resizable instance of the class based on the specified byte array.
bufferThe array of unsigned bytes from which to create the current stream.
public MemoryStream( byte[] buffer, bool writable )
Initializes a new non-resizable instance of the class based on the specified byte array with the property set as specified.
bufferThe array of unsigned bytes from which to create this stream.writableThe setting of the property, which determines whether the stream supports writing.
public MemoryStream( byte[] buffer, int index, int count )
Initializes a new non-resizable instance of the class based on the specified region (index) of a byte array.
bufferThe array of unsigned bytes from which to create this stream.indexThe index into at which the stream begins.countThe length of the stream in bytes.
public MemoryStream( byte[] buffer, int index, int count, bool writable )
Initializes a new non-resizable instance of the class based on the specified region of a byte array, with the property set as specified.
bufferThe array of unsigned bytes from which to create this stream.indexThe index in at which the stream begins.countThe length of the stream in bytes.writableThe setting of the property, which determines whether the stream supports writing.
public MemoryStream( byte[] buffer, int index, int count, bool writable, bool publiclyVisible )
Initializes a new instance of the class based on the specified region of a byte array, with the property set as specified, and the ability to call set as specified.
bufferThe array of unsigned bytes from which to create this stream.indexThe index into at which the stream begins.countThe length of the stream in bytes.writableThe setting of the property, which determines whether the stream supports writing.publiclyVisibleto enable , which returns the unsigned byte array from which the stream was created; otherwise, .
public MemoryStream( int capacity )
Initializes a new instance of the class with an expandable capacity initialized as specified.
capacityThe initial size of the internal array in bytes.
public IAsyncResult BeginRead( byte[] buffer, int offset, int count, AsyncCallback callback, object state )
No summary.
public IAsyncResult BeginWrite( byte[] buffer, int offset, int count, AsyncCallback callback, object state )
No summary.
public bool CanRead { get; }
Gets a value indicating whether the current stream supports reading.
- Returns if the stream is open.
public bool CanSeek { get; }
Gets a value indicating whether the current stream supports seeking.
- Returns if the stream is open.
public bool CanWrite { get; }
Gets a value indicating whether the current stream supports writing.
- Returns if the stream supports writing; otherwise, .
public int Capacity { get; set; }
Gets or sets the number of bytes allocated for this stream.
- Returns The length of the usable portion of the buffer for the stream.
public void CopyTo( Stream destination, int bufferSize )
No summary.
public Task CopyToAsync( Stream destination, int bufferSize, CancellationToken cancellationToken )
Asynchronously reads all the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.
destinationThe stream to which the contents of the current stream will be copied.bufferSizeThe size, in bytes, of the buffer. This value must be greater than zero.cancellationTokenThe token to monitor for cancellation requests.- Returns A task that represents the asynchronous copy operation.
public int EndRead( IAsyncResult asyncResult )
No summary.
public void EndWrite( IAsyncResult asyncResult )
No summary.
public Task FlushAsync( CancellationToken cancellationToken )
Asynchronously clears all buffers for this stream, and monitors cancellation requests.
cancellationTokenThe token to monitor for cancellation requests.- Returns A task that represents the asynchronous flush operation.
public long Length { get; }
Gets the length of the stream in bytes.
- Returns The length of the stream in bytes.
public long Position { get; set; }
Gets or sets the current position within the stream.
- Returns The current position within the stream.
public int Read( byte[] buffer, int offset, int count )
Reads a block of bytes from the current stream and writes the data to a buffer.
bufferWhen this method returns, contains the specified byte array with the values between and ( + - 1) replaced by the characters read from the current stream.offsetThe zero-based byte offset in at which to begin storing data from the current stream.countThe maximum number of bytes to read.- Returns The total number of bytes written into the buffer. This can be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached before any bytes are read.
public Task<int> ReadAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken )
Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
bufferThe buffer to write the data into.offsetThe byte offset in at which to begin writing data from the stream.countThe maximum number of bytes to read.cancellationTokenThe token to monitor for cancellation requests. The default value is .- Returns A task that represents the asynchronous read operation. The value of the parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the stream has been reached.
public long Seek( long offset, SeekOrigin loc )
Sets the position within the current stream to the specified value.
offsetThe new position within the stream. This is relative to the parameter, and can be positive or negative.locA value of type , which acts as the seek reference point.- Returns The new position within the stream, calculated by combining the initial reference point and the offset.
public void SetLength( long value )
Sets the length of the current stream to the specified value.
valueThe value at which to set the length.
public void Write( byte[] buffer, int offset, int count )
Writes a block of bytes to the current stream using data read from a buffer.
bufferThe buffer to write data from.offsetThe zero-based byte offset in at which to begin copying bytes to the current stream.countThe maximum number of bytes to write.
public Task WriteAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken )
Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
bufferThe buffer to write data from.offsetThe zero-based byte offset in from which to begin copying bytes to the stream.countThe maximum number of bytes to write.cancellationTokenThe token to monitor for cancellation requests. The default value is .- Returns A task that represents the asynchronous write operation.
public void WriteByte( byte value )
Writes a byte to the current stream at the current position.
valueThe byte to write.
public void WriteTo( Stream stream )
Writes the entire contents of this memory stream to another stream.
streamThe stream to write this memory stream to.
public bool Equals( object obj )
😔 No documentation found.
public string ToString( )
😔 No documentation found.
public Type GetType( )
😔 No documentation found.
public object InitializeLifetimeService( )
😔 No documentation found.
public byte[] GetBuffer( )
😔 No documentation found.
public object GetLifetimeService( )
😔 No documentation found.
public int ReadAtLeast( Span<byte> buffer, int minimumBytes, bool throwOnEndOfStream = True )
😔 No documentation found.
public void ReadExactly( byte[] buffer, int offset, int count )
😔 No documentation found.
public void ReadExactly( Span<byte> buffer )
😔 No documentation found.
public int GetHashCode( )
😔 No documentation found.
public Task WriteAsync( byte[] buffer, int offset, int count )
😔 No documentation found.
public MemoryStream( )
😔 No documentation found.
public void Flush( )
😔 No documentation found.
public ValueTask<int> ReadAtLeastAsync( Memory<byte> buffer, int minimumBytes, bool throwOnEndOfStream = True, CancellationToken cancellationToken = null )
😔 No documentation found.
public Task CopyToAsync( Stream destination )
😔 No documentation found.
public ValueTask DisposeAsync( )
😔 No documentation found.
public int Read( Span<byte> buffer )
😔 No documentation found.
public ValueTask<int> ReadAsync( Memory<byte> buffer, CancellationToken cancellationToken = null )
😔 No documentation found.
public int ReadByte( )
😔 No documentation found.
public byte[] ToArray( )
😔 No documentation found.
public void Write( ReadOnlySpan<byte> buffer )
😔 No documentation found.
public ValueTask WriteAsync( ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = null )
😔 No documentation found.
public bool CanTimeout { get; }
😔 No documentation found.
public int ReadTimeout { get; set; }
😔 No documentation found.
public int WriteTimeout { get; set; }
😔 No documentation found.
public void CopyTo( Stream destination )
😔 No documentation found.
public Task CopyToAsync( Stream destination, int bufferSize )
😔 No documentation found.
public Task CopyToAsync( Stream destination, CancellationToken cancellationToken )
😔 No documentation found.
public void Dispose( )
😔 No documentation found.
public void Close( )
😔 No documentation found.
public Task FlushAsync( )
😔 No documentation found.
public bool TryGetBuffer( ref ArraySegment<byte> buffer )
😔 No documentation found.
public Task<int> ReadAsync( byte[] buffer, int offset, int count )
😔 No documentation found.
public ValueTask ReadExactlyAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken = null )
😔 No documentation found.
public ValueTask ReadExactlyAsync( Memory<byte> buffer, CancellationToken cancellationToken = null )
😔 No documentation found.