Прочетете на английски Редактиране

Споделяне чрез


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.

C#
public BufferedStream(System.IO.Stream 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

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.5, 1.6, 2.0, 2.1

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.

C#
public BufferedStream(System.IO.Stream stream, int bufferSize);

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.

C#
// 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))

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

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.5, 1.6, 2.0, 2.1