BufferedStream 建構函式

定義

初始化 BufferedStream 類別的新執行個體。Initializes a new instance of the BufferedStream class.

多載

BufferedStream(Stream)

使用 4096 位元組的預設緩衝區大小,來初始化 BufferedStream 類別的新執行個體。Initializes a new instance of the BufferedStream class with a default buffer size of 4096 bytes.

BufferedStream(Stream, Int32)

使用指定的緩衝區大小來初始化 BufferedStream 類別的新執行個體。Initializes a new instance of the BufferedStream class with the specified buffer size.

BufferedStream(Stream)

使用 4096 位元組的預設緩衝區大小,來初始化 BufferedStream 類別的新執行個體。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

參數

stream
Stream

目前的資料流。The current stream.

例外狀況

streamnullstream is null.

備註

第一次使用此函式初始化 BufferedStream 物件時,會配置共用的讀取/寫入緩衝區。A shared read/write buffer is allocated the first time a BufferedStream object is initialized with this constructor. 如果所有讀取和寫入都大於或等於 bufferSize,則不會使用共用緩衝區。The shared buffer is not used if all reads and writes are greater than or equal to bufferSize.

另請參閱

BufferedStream(Stream, Int32)

使用指定的緩衝區大小來初始化 BufferedStream 類別的新執行個體。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

參數

stream
Stream

目前的資料流。The current stream.

bufferSize
Int32

緩衝區大小,以位元組為單位。The buffer size in bytes.

例外狀況

streamnullstream is null.

bufferSize 為負。bufferSize is negative.

範例

這個程式碼範例是針對 BufferedStream 類別所提供的較大範例的一部分。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.
Dim netStream As New NetworkStream(clientSocket, True)
Dim bufStream As New _
    BufferedStream(netStream, streamBufferSize)

備註

第一次使用此函式初始化 BufferedStream 物件時,會配置共用的讀取/寫入緩衝區。A shared read/write buffer is allocated the first time a BufferedStream object is initialized with this constructor. 如果所有讀取和寫入都大於或等於 bufferSize,則不會使用共用緩衝區。The shared buffer is not used if all reads and writes are greater than or equal to bufferSize.

另請參閱

適用於