BufferedStream 构造函数

定义

初始化 BufferedStream 类的新实例。

重载

BufferedStream(Stream)

使用默认的缓冲区大小 4096 字节初始化 BufferedStream 类的新实例。

BufferedStream(Stream, Int32)

使用指定的缓冲区大小初始化 BufferedStream 类的新实例。

BufferedStream(Stream)

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

使用默认的缓冲区大小 4096 字节初始化 BufferedStream 类的新实例。

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)

参数

stream
Stream

当前流。

例外

streamnull

注解

首次使用此构造函数初始化对象时 BufferedStream ,将分配共享读/写缓冲区。 如果所有读取和写入都大于或等于 bufferSize,则不会使用共享缓冲区。

另请参阅

适用于

BufferedStream(Stream, Int32)

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

使用指定的缓冲区大小初始化 BufferedStream 类的新实例。

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)

参数

stream
Stream

当前流。

bufferSize
Int32

缓冲区大小(以字节为单位)。

例外

streamnull

bufferSize 为负数。

示例

此代码示例是为 BufferedStream 类提供的一个更大示例的一部分。

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

注解

首次使用此构造函数初始化对象时 BufferedStream ,将分配共享读/写缓冲区。 如果所有读取和写入都大于或等于 bufferSize,则不会使用共享缓冲区。

另请参阅

适用于