StringWriter StringWriter StringWriter StringWriter Class

定义

实现一个用于将信息写入字符串的 TextWriter Implements a TextWriter for writing information to a string. 该信息存储在基础 StringBuilder 中。 The information is stored in an underlying StringBuilder.

public ref class StringWriter : System::IO::TextWriter
[System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class StringWriter : System.IO.TextWriter
type StringWriter = class
    inherit TextWriter
Public Class StringWriter
Inherits TextWriter
继承
属性
ComVisibleAttribute SerializableAttribute

示例

下面的代码示例演示创建一个连续的段落从一组双倍的句子,然后在段落的转换回原始的文本。The following code example demonstrates the creation of a continuous paragraph from a group of double-spaced sentences, and then the conversion of the paragraph back to the original text.

using namespace System;
using namespace System::IO;
int main()
{
   String^ textReaderText = "TextReader is the abstract base "
   "class of StreamReader and StringReader, which read "
   "characters from streams and strings, respectively.\n\n"
   "Create an instance of TextReader to open a text file "
   "for reading a specified range of characters, or to "
   "create a reader based on an existing stream.\n\n"
   "You can also use an instance of TextReader to read "
   "text from a custom backing store using the same "
   "APIs you would use for a string or a stream.\n\n";
   Console::WriteLine(  "Original text:\n\n{0}", textReaderText );

   // From textReaderText, create a continuous paragraph 
   // with two spaces between each sentence.
      String^ aLine;
   String^ aParagraph;
   StringReader^ strReader = gcnew StringReader( textReaderText );
   while ( true )
   {
      aLine = strReader->ReadLine();
      if ( aLine != nullptr )
      {
         aParagraph = String::Concat( aParagraph, aLine,  " " );
      }
      else
      {
         aParagraph = String::Concat( aParagraph,  "\n" );
         break;
      }
   }

   Console::WriteLine(  "Modified text:\n\n{0}", aParagraph );
   
   // Re-create textReaderText from aParagraph.
   int intCharacter;
   Char convertedCharacter;
   StringWriter^ strWriter = gcnew StringWriter;
   strReader = gcnew StringReader( aParagraph );
   while ( true )
   {
      intCharacter = strReader->Read();
      
      // Check for the end of the string 
      // before converting to a character.
      if ( intCharacter == -1 )
            break;

      
      convertedCharacter = Convert::ToChar( intCharacter );
      if ( convertedCharacter == '.' )
      {
         strWriter->Write(  ".\n\n" );
         
         // Bypass the spaces between sentences.
         strReader->Read();
         strReader->Read();
      }
      else
      {
         strWriter->Write( convertedCharacter );
      }
   }

   Console::WriteLine(  "\nOriginal text:\n\n{0}", strWriter->ToString() );
}

using System;
using System.IO;

class StringRW
{
    static void Main()
    {
        string textReaderText = "TextReader is the abstract base " +
            "class of StreamReader and StringReader, which read " +
            "characters from streams and strings, respectively.\n\n" +

            "Create an instance of TextReader to open a text file " +
            "for reading a specified range of characters, or to " +
            "create a reader based on an existing stream.\n\n" +

            "You can also use an instance of TextReader to read " +
            "text from a custom backing store using the same " +
            "APIs you would use for a string or a stream.\n\n";

        Console.WriteLine("Original text:\n\n{0}", textReaderText);

        // From textReaderText, create a continuous paragraph 
        // with two spaces between each sentence.
        string aLine, aParagraph = null;
        StringReader strReader = new StringReader(textReaderText);
        while(true)
        {
            aLine = strReader.ReadLine();
            if(aLine != null)
            {
                aParagraph = aParagraph + aLine + " ";
            }
            else
            {
                aParagraph = aParagraph + "\n";
                break;
            }
        }
        Console.WriteLine("Modified text:\n\n{0}", aParagraph);

        // Re-create textReaderText from aParagraph.
        int intCharacter;
        char convertedCharacter;
        StringWriter strWriter = new StringWriter();
        strReader = new StringReader(aParagraph);
        while(true)
        {
            intCharacter = strReader.Read();

            // Check for the end of the string 
            // before converting to a character.
            if(intCharacter == -1) break;

            convertedCharacter = Convert.ToChar(intCharacter);
            if(convertedCharacter == '.')
            {
                strWriter.Write(".\n\n");

                // Bypass the spaces between sentences.
                strReader.Read();
                strReader.Read();
            }
            else
            {
                strWriter.Write(convertedCharacter);
            }
        }
        Console.WriteLine("\nOriginal text:\n\n{0}", 
            strWriter.ToString());
    }
}
Option Explicit
Option Strict

Imports Microsoft.VisualBasic
Imports System
Imports System.IO

Public Class StrReader

    Shared Sub Main()
    
        Dim textReaderText As String = "TextReader is the " & _
            "abstract base class of StreamReader and " & _
            "StringReader, which read characters from streams " & _
            "and strings, respectively." & _
            vbCrLf & vbCrLf & _
            "Create an instance of TextReader to open a text " & _
            "file for reading a specified range of characters, " & _
            "or to create a reader based on an existing stream." & _
            vbCrLf & vbCrLf & _
            "You can also use an instance of TextReader to read " & _
            "text from a custom backing store using the same " & _
            "APIs you would use for a string or a stream." & _
            vbCrLf & vbCrLf

        Console.WriteLine("Original text:" & vbCrLf & vbCrLf & _
            textReaderText)

        ' From textReaderText, create a continuous paragraph 
        ' with two spaces between each sentence.
        Dim aLine, aParagraph As String
        Dim strReader As New StringReader(textReaderText)
        While True
            aLine = strReader.ReadLine()
            If aLine Is Nothing Then
                aParagraph = aParagraph & vbCrLf
                Exit While
            Else
                aParagraph = aParagraph & aLine & " "
            End If
        End While
        Console.WriteLine("Modified text:" & vbCrLf & vbCrLf & _ 
            aParagraph)
    
        ' Re-create textReaderText from aParagraph.
        Dim intCharacter As Integer 
        Dim convertedCharacter As Char 
        Dim strWriter As New StringWriter()
        strReader = New StringReader(aParagraph)
        While True
            intCharacter = strReader.Read()

            ' Check for the end of the string 
            ' before converting to a character.
            If intCharacter = -1 Then
                Exit While
            End If

            convertedCharacter = Convert.ToChar(intCharacter)
            If convertedCharacter = "."C Then
                strWriter.Write("." & vbCrLf & vbCrLf)

                ' Bypass the spaces between sentences.
                strReader.Read()
                strReader.Read()
            Else
                strWriter.Write(convertedCharacter)
            End If
        End While
        Console.WriteLine(vbCrLf & "Original text:" & vbCrLf & _ 
            vbCrLf & strWriter.ToString())

    End Sub
End Class

注解

StringWriter 可以以同步方式还是以异步方式向字符串写入。StringWriter enables you to write to a string synchronously or asynchronously. 可以将字符写入一次Write(Char)WriteAsync(Char)方法中,在时使用字符串Write(String)WriteAsync(String)方法。You can write a character at a time with the Write(Char) or the WriteAsync(Char) method, a string at a time using the Write(String) or the WriteAsync(String) method. 此外,可以编写字符、 字符数组或字符串并按以异步方式使用的一个行结束符WriteLineAsync方法。In addition, you can write a character, an array of characters or a string followed by the line terminator asynchronously with one of the WriteLineAsync methods.

备注

此类型可实现 IDisposable 接口,但实际上没有任何要释放的资源。This type implements the IDisposable interface, but does not actually have any resources to dispose. 这意味着无需通过直接调用 Dispose() 或使用语言构造(C# 中的 using 或 Visual Basic 中的 Using)对其进行处理。This means that disposing it by directly calling Dispose() or by using a language construct such as using (in C#) or Using (in Visual Basic) is not necessary.

下表列出了其他典型或相关的 I/O 任务的示例。The following table lists examples of other typical or related I/O tasks.

若要执行此操作...To do this... 请参见本主题中的示例...See the example in this topic...
创建文本文件。Create a text file. 如何:向文件写入文本How to: Write Text to a File
写入一个文本文件。Write to a text file. 如何:向文件写入文本How to: Write Text to a File
从文本文件中读取。Read from a text file. 如何:从文件读取文本How to: Read Text from a File
将文本追加到文件。Append text to a file. 如何:打开并追加到日志文件How to: Open and Append to a Log File

File.AppendText

FileInfo.AppendText
获取文件的大小。Get the size of a file. FileInfo.Length
获取文件的属性。Get the attributes of a file. File.GetAttributes
设置文件的属性。Set the attributes of a file. File.SetAttributes
确定文件是否存在。Determine if a file exists. File.Exists
从二进制文件中读取。Read from a binary file. 如何:对新建的数据文件进行读取和写入How to: Read and Write to a Newly Created Data File
写入二进制文件。Write to a binary file. 如何:对新建的数据文件进行读取和写入How to: Read and Write to a Newly Created Data File

构造函数

StringWriter() StringWriter() StringWriter() StringWriter()

初始化 StringWriter 类的新实例。 Initializes a new instance of the StringWriter class.

StringWriter(IFormatProvider) StringWriter(IFormatProvider) StringWriter(IFormatProvider) StringWriter(IFormatProvider)

使用指定的格式控制初始化 StringWriter 类的新实例。 Initializes a new instance of the StringWriter class with the specified format control.

StringWriter(StringBuilder) StringWriter(StringBuilder) StringWriter(StringBuilder) StringWriter(StringBuilder)

初始化写入指定 StringWriterStringBuilder 类的新实例。 Initializes a new instance of the StringWriter class that writes to the specified StringBuilder.

StringWriter(StringBuilder, IFormatProvider) StringWriter(StringBuilder, IFormatProvider) StringWriter(StringBuilder, IFormatProvider) StringWriter(StringBuilder, IFormatProvider)

初始化写入指定 StringWriter 并具有指定格式提供程序的 StringBuilder 类的新实例。 Initializes a new instance of the StringWriter class that writes to the specified StringBuilder and has the specified format provider.

属性

Encoding Encoding Encoding Encoding

获取在其中写入输出的 Encoding Gets the Encoding in which the output is written.

FormatProvider FormatProvider FormatProvider FormatProvider

获取控制格式设置的对象。 Gets an object that controls formatting.

(Inherited from TextWriter)
NewLine NewLine NewLine NewLine

获取或设置由当前 TextWriter 使用的行结束符字符串。 Gets or sets the line terminator string used by the current TextWriter.

(Inherited from TextWriter)

方法

Close() Close() Close() Close()

关闭当前的 StringWriter 和基础流。 Closes the current StringWriter and the underlying stream.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

释放由 TextWriter 对象使用的所有资源。 Releases all resources used by the TextWriter object.

(Inherited from TextWriter)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 StringWriter 占用的非托管资源,还可以另外再释放托管资源。 Releases the unmanaged resources used by the StringWriter and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。 Determines whether the specified object is equal to the current object.

(Inherited from Object)
Flush() Flush() Flush() Flush()

清理当前编写器的所有缓冲区,使所有缓冲数据写入基础设备。 Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

(Inherited from TextWriter)
FlushAsync() FlushAsync() FlushAsync() FlushAsync()

异步清理当前编写器的所有缓冲区,使所有缓冲数据写入基础设备。 Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。 Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。 Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetStringBuilder() GetStringBuilder() GetStringBuilder() GetStringBuilder()

返回基础 StringBuilder Returns the underlying StringBuilder.

GetType() GetType() GetType() GetType()

获取当前实例的 Type Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。 Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。 Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。 Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

返回包含迄今为止写入到当前 StringWriter 中的字符的字符串。 Returns a string containing the characters written to the current StringWriter so far.

Write(Boolean) Write(Boolean) Write(Boolean) Write(Boolean)

Boolean 值的文本表示形式写入文本字符串或流。 Writes the text representation of a Boolean value to the text string or stream.

(Inherited from TextWriter)
Write(Char) Write(Char) Write(Char) Write(Char)

将字符写入字符串。 Writes a character to the string.

Write(Char[]) Write(Char[]) Write(Char[]) Write(Char[])

将字符数组写入该文本字符串或流。 Writes a character array to the text string or stream.

(Inherited from TextWriter)
Write(Char[], Int32, Int32) Write(Char[], Int32, Int32) Write(Char[], Int32, Int32) Write(Char[], Int32, Int32)

将字符的子数组写入字符串。 Writes a subarray of characters to the string.

Write(Decimal) Write(Decimal) Write(Decimal) Write(Decimal)

将十进制值的文本表示形式写入文本字符串或流。 Writes the text representation of a decimal value to the text string or stream.

(Inherited from TextWriter)
Write(Double) Write(Double) Write(Double) Write(Double)

将 8 字节浮点值的文本表示形式写入文本字符串或流。 Writes the text representation of an 8-byte floating-point value to the text string or stream.

(Inherited from TextWriter)
Write(Int32) Write(Int32) Write(Int32) Write(Int32)

将 4 字节有符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of a 4-byte signed integer to the text string or stream.

(Inherited from TextWriter)
Write(Int64) Write(Int64) Write(Int64) Write(Int64)

将 8 字节有符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of an 8-byte signed integer to the text string or stream.

(Inherited from TextWriter)
Write(Object) Write(Object) Write(Object) Write(Object)

通过在对象上调用 ToString 方法将此对象的文本表示形式写入文本字符串或流。 Writes the text representation of an object to the text string or stream by calling the ToString method on that object.

(Inherited from TextWriter)
Write(ReadOnlySpan<Char>) Write(ReadOnlySpan<Char>) Write(ReadOnlySpan<Char>) Write(ReadOnlySpan<Char>)
Write(Single) Write(Single) Write(Single) Write(Single)

将 4 字节浮点值的文本表示形式写入文本字符串或流。 Writes the text representation of a 4-byte floating-point value to the text string or stream.

(Inherited from TextWriter)
Write(String) Write(String) Write(String) Write(String)

将字符串写入当前字符串。 Writes a string to the current string.

Write(String, Object) Write(String, Object) Write(String, Object) Write(String, Object)

使用与 Format(String, Object) 方法相同的语义将格式化字符串和新行写入文本字符串或流。 Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object) method.

(Inherited from TextWriter)
Write(String, Object, Object) Write(String, Object, Object) Write(String, Object, Object) Write(String, Object, Object)

使用与 Format(String, Object, Object) 方法相同的语义将格式化字符串和新行写入文本字符串或流。 Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object, Object) method.

(Inherited from TextWriter)
Write(String, Object, Object, Object) Write(String, Object, Object, Object) Write(String, Object, Object, Object) Write(String, Object, Object, Object)

使用与 Format(String, Object, Object, Object) 方法相同的语义将格式化字符串和新行写入文本字符串或流。 Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object, Object, Object) method.

(Inherited from TextWriter)
Write(String, Object[]) Write(String, Object[]) Write(String, Object[]) Write(String, Object[])

使用与 Format(String, Object[]) 方法相同的语义将格式化字符串和新行写入文本字符串或流。 Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object[]) method.

(Inherited from TextWriter)
Write(UInt32) Write(UInt32) Write(UInt32) Write(UInt32)

将 4 字节无符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of a 4-byte unsigned integer to the text string or stream.

(Inherited from TextWriter)
Write(UInt64) Write(UInt64) Write(UInt64) Write(UInt64)

将 8 字节无符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of an 8-byte unsigned integer to the text string or stream.

(Inherited from TextWriter)
WriteAsync(Char) WriteAsync(Char) WriteAsync(Char) WriteAsync(Char)

将字符异步写入该字符串。 Writes a character to the string asynchronously.

WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[])

以异步形式将字符数组写入到下一个字符串或流。 Writes a character array to the text string or stream asynchronously.

(Inherited from TextWriter)
WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32)

将字符的子数组异步写入字符串。 Writes a subarray of characters to the string asynchronously.

WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken)
WriteAsync(String) WriteAsync(String) WriteAsync(String) WriteAsync(String)

以异步方式将字符串写入当前流。 Writes a string to the current string asynchronously.

WriteLine() WriteLine() WriteLine() WriteLine()

将行结束符的字符串写入文本字符串或流。 Writes a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean)

将后面带有行结束符的 Boolean 值的文本表示形式写入文本字符串或流。 Writes the text representation of a Boolean value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Char) WriteLine(Char) WriteLine(Char) WriteLine(Char)

将后跟行结束符的字符写入文本字符串或流。 Writes a character followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[])

将后跟行结束符的字符数组写入文本字符串或流。 Writes an array of characters followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32)

将后跟行结束符的字符子数组写入文本字符串或流。 Writes a subarray of characters followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Decimal) WriteLine(Decimal) WriteLine(Decimal) WriteLine(Decimal)

将后面带有行结束符的十进制值的文本表示形式写入文本字符串或流。 Writes the text representation of a decimal value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Double) WriteLine(Double) WriteLine(Double) WriteLine(Double)

将后跟行结束符的 8 字节浮点值的文本表示形式写入文本字符串或流。 Writes the text representation of a 8-byte floating-point value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Int32) WriteLine(Int32) WriteLine(Int32) WriteLine(Int32)

将后跟行结束符的 4 字节有符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of a 4-byte signed integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Int64) WriteLine(Int64) WriteLine(Int64) WriteLine(Int64)

将后跟行结束符的 8 字节有符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of an 8-byte signed integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Object) WriteLine(Object) WriteLine(Object) WriteLine(Object)

通过在对象上调用 ToString 方法将后跟行结束符的此对象的文本表示形式写入文本字符串或流。 Writes the text representation of an object by calling the ToString method on that object, followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(ReadOnlySpan<Char>) WriteLine(ReadOnlySpan<Char>) WriteLine(ReadOnlySpan<Char>) WriteLine(ReadOnlySpan<Char>)
WriteLine(Single) WriteLine(Single) WriteLine(Single) WriteLine(Single)

将后跟行结束符的 4 字节浮点值的文本表示形式写入文本字符串或流。 Writes the text representation of a 4-byte floating-point value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(String) WriteLine(String) WriteLine(String) WriteLine(String)

将后跟行结束符的字符串写入文本字符串或流。 Writes a string followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object)

使用与 Format(String, Object) 方法相同的语义将格式化字符串和新行写入文本字符串或流。 Writes a formatted string and a new line to the text string or stream, using the same semantics as the Format(String, Object) method.

(Inherited from TextWriter)
WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object)

使用与 Format(String, Object, Object) 方法相同的语义将格式化字符串和新行写入文本字符串或流。 Writes a formatted string and a new line to the text string or stream, using the same semantics as the Format(String, Object, Object) method.

(Inherited from TextWriter)
WriteLine(String, Object, Object, Object) WriteLine(String, Object, Object, Object) WriteLine(String, Object, Object, Object) WriteLine(String, Object, Object, Object)

使用与 Format(String, Object) 相同的语义写出格式化的字符串和一个新行。 Writes out a formatted string and a new line, using the same semantics as Format(String, Object).

(Inherited from TextWriter)
WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[])

使用与 Format(String, Object) 相同的语义写出格式化的字符串和一个新行。 Writes out a formatted string and a new line, using the same semantics as Format(String, Object).

(Inherited from TextWriter)
WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32)

将后跟行结束符的 4 字节无符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of a 4-byte unsigned integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(UInt64) WriteLine(UInt64) WriteLine(UInt64) WriteLine(UInt64)

将后跟行结束符的 8 字节无符号整数的文本表示形式写入文本字符串或流。 Writes the text representation of an 8-byte unsigned integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLineAsync() WriteLineAsync() WriteLineAsync() WriteLineAsync()

将行结束符的字符串异步写入文本字符串或流。 Writes a line terminator asynchronously to the text string or stream.

(Inherited from TextWriter)
WriteLineAsync(Char) WriteLineAsync(Char) WriteLineAsync(Char) WriteLineAsync(Char)

将后跟行终止符的字符异步写入字符串。 Writes a character followed by a line terminator asynchronously to the string.

WriteLineAsync(Char[]) WriteLineAsync(Char[]) WriteLineAsync(Char[]) WriteLineAsync(Char[])

将后跟行结束符的字符数组异步写入文本字符串或流。 Writes an array of characters followed by a line terminator asynchronously to the text string or stream.

(Inherited from TextWriter)
WriteLineAsync(Char[], Int32, Int32) WriteLineAsync(Char[], Int32, Int32) WriteLineAsync(Char[], Int32, Int32) WriteLineAsync(Char[], Int32, Int32)

将后跟行结束符的字符子数组异步写入该字符串。 Writes a subarray of characters followed by a line terminator asynchronously to the string.

WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken) WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken) WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken) WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken)
WriteLineAsync(String) WriteLineAsync(String) WriteLineAsync(String) WriteLineAsync(String)

将后跟行终止符的字符串异步写入当前字符串。 Writes a string followed by a line terminator asynchronously to the current string.

字段

CoreNewLine CoreNewLine CoreNewLine CoreNewLine

存储用于此 TextWriter 的换行符。 Stores the newline characters used for this TextWriter.

(Inherited from TextWriter)

显式界面实现

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() Inherited from TextWriter

适用于

另请参阅