StreamWriter.Null 字段

定义

提供一个 StreamWriter 没有可写入到但无法从中读取的后盾存储。

public: static initonly System::IO::StreamWriter ^ Null;
public static readonly System.IO.StreamWriter Null;
 staticval mutable Null : System.IO.StreamWriter
Public Shared ReadOnly Null As StreamWriter 

字段值

示例

以下示例演示了该 Null 字段的使用。

if(sw.Equals(StreamWriter.Null))
{
    sw.WriteLine("The store can be written to, but not read from.");
}
If Sw.Equals(StreamWriter.Null) Then
    Sw.WriteLine("The store can be written to, but not read from.")
End If

注解

用于 Null 将输出重定向到 StreamWriter 不会消耗任何操作系统资源的输出。

StreamWriter.Write调用方法Null时,调用只会返回,实际上不会将数据写入任何后盾存储。

有关常见 I/O 任务的列表,请参阅 常见 I/O 任务

适用于

另请参阅