BufferedStream Constructors

Definition

Initializes a new instance of the BufferedStream class.

Overloads

BufferedStream(Stream)

Initializes a new instance of the BufferedStream class with a default buffer size of 4096 bytes.

BufferedStream(Stream, Int32)

Initializes a new instance of the BufferedStream class with the specified buffer size.

BufferedStream(Stream)

Source:
BufferedStream.cs
Source:
BufferedStream.cs
Source:
BufferedStream.cs

Initializes a new instance of the BufferedStream class with a default buffer size of 4096 bytes.

public:
 BufferedStream(System::IO::Stream ^ stream);
public BufferedStream (System.IO.Stream stream);
new System.IO.BufferedStream : System.IO.Stream -> System.IO.BufferedStream
Public Sub New (stream As Stream)

Parameters

stream
Stream

The current stream.

Exceptions

stream is null.

Remarks

A shared read/write buffer is allocated the first time a BufferedStream object is initialized with this constructor. The shared buffer is not used if all reads and writes are greater than or equal to bufferSize.

See also

Applies to

BufferedStream(Stream, Int32)

Source:
BufferedStream.cs
Source:
BufferedStream.cs
Source:
BufferedStream.cs

Initializes a new instance of the BufferedStream class with the specified buffer size.

public:
 BufferedStream(System::IO::Stream ^ stream, int bufferSize);
public BufferedStream (System.IO.Stream stream, int bufferSize);
new System.IO.BufferedStream : System.IO.Stream * int -> System.IO.BufferedStream
Public Sub New (stream As Stream, bufferSize As Integer)

Parameters

stream
Stream

The current stream.

bufferSize
Int32

The buffer size in bytes.

Exceptions

stream is null.

bufferSize is negative.

Examples

This code example is part of a larger example provided for the BufferedStream class.

// Create a NetworkStream that owns clientSocket and 
// then create a BufferedStream on top of the NetworkStream.
NetworkStream^ netStream = gcnew NetworkStream( clientSocket,true );
BufferedStream^ bufStream = gcnew BufferedStream( netStream,streamBufferSize );
// Create a NetworkStream that owns clientSocket and
// then create a BufferedStream on top of the NetworkStream.
// Both streams are disposed when execution exits the
// using statement.
using(Stream
    netStream = new NetworkStream(clientSocket, true),
    bufStream =
          new BufferedStream(netStream, streamBufferSize))
// Create a NetworkStream that owns clientSocket and
// then create a BufferedStream on top of the NetworkStream.
// Both streams are disposed when execution exits the
// using statement.
use netStream = new NetworkStream(clientSocket, true)
use bufStream = new BufferedStream(netStream, streamBufferSize)
' Create a NetworkStream that owns clientSocket and then 
' create a BufferedStream on top of the NetworkStream.
Dim netStream As New NetworkStream(clientSocket, True)
Dim bufStream As New _
    BufferedStream(netStream, streamBufferSize)

Remarks

A shared read/write buffer is allocated the first time a BufferedStream object is initialized with this constructor. The shared buffer is not used if all reads and writes are greater than or equal to bufferSize.

See also

Applies to