当使用.NET BufferedStream类?NET、BufferedStream

2023-09-02 10:31:01 作者:念旧的人总像个拾荒者

借助 MSDN网站状态:

一个缓冲区是内存中的字节块   用于高速缓存数据,从而减少了   调用操作的数目   系统。缓冲器来提高读取和写入   性能。缓冲可以用于   读出或写入,但从来没有   两者同时进行。读取和   写BufferedStream方法   自动维护缓冲区。

A buffer is a block of bytes in memory used to cache data, thereby reducing the number of calls to the operating system. Buffers improve read and write performance. A buffer can be used for either reading or writing, but never both simultaneously. The Read and Write methods of BufferedStream automatically maintain the buffer.

我应该在一切可能的场合使用这个类?

Should I use this class in every possible occasion?

推荐答案

以下是从网上当然我采取了一些文本:

The following is some text from an online course I am taking:

该BufferedStream类是一个具体   扩展Stream类类   并用于提供额外的   存储器缓冲器到另一种类型的   流,同步和   异步的。该BufferedStream   类必须适当配置可以   读或写的,当一个实例   类被创建,但   BufferedStream不能被配置以   在相同的执行这两个任务   时间。

The BufferedStream class is a concrete class that extends the Stream class and is used to provide an additional memory buffer to another type of stream, both synchronously and asynchronously. The BufferedStream class must be configured to either read or write when an instance of the class is created, but the BufferedStream cannot be configured to perform both the tasks at the same time.

微软改进的性能   在.NET Framework中的所有数据流通过   包括一个内置的缓冲器。该   性能显着改良   应用BufferedStream现有   流,例如FileStream或   MemoryStream的。应用   BufferedStream到现有的.NET   框架流导致双   缓冲区。

Microsoft improved the performance of all streams in the .NET Framework by including a built-in buffer. The performance noticeably improved by applying a BufferedStream to existing streams, such as a FileStream or MemoryStream. Applying a BufferedStream to an existing .NET Framework stream results in a double buffer.

的最常见的应用   BufferedStream类是定制   流类不包括   内置缓冲

The most common application of the BufferedStream class is in custom stream classes that do not include a built-in buffer.