StreamWriter.Null 字段
定义
提供 StreamWriter,它不带任何可写入但无法从中读取的后备存储。Provides a StreamWriter with no backing store that can be written to, but not read from.
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 字段。The following example demonstrates a use of the Null field.
if ( sw->Equals( StreamWriter::Null ) )
{
sw->WriteLine( "The store can be written to, but not read from." );
}
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 不会消耗任何操作系统资源的。Use Null to redirect output to a StreamWriter that will not consume any operating system resources.
当 StreamWriter.Write 在上调用方法时 Null ,调用只会返回,而不会向任何后备存储写入任何数据。When the StreamWriter.Write methods are invoked on Null, the call simply returns, and no data is actually written to any backing store.
有关常见 i/o 任务的列表,请参阅 常见 I/o 任务。For a list of common I/O tasks, see Common I/O Tasks.