StringWriter 類別

定義

實作 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
public class StringWriter : System.IO.TextWriter
[System.Serializable]
public class StringWriter : System.IO.TextWriter
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class StringWriter : System.IO.TextWriter
type StringWriter = class
    inherit TextWriter
[<System.Serializable>]
type StringWriter = class
    inherit TextWriter
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type StringWriter = class
    inherit TextWriter
Public Class StringWriter
Inherits TextWriter
繼承
StringWriter
繼承
屬性

範例

下列程式碼範例示範如何從兩個空格的句子群組建立連續段落,然後將段落轉換回原始文字。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 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. 此外,您可以使用其中一個方法,以非同步方式撰寫字元、字元陣列或字串,後面接著行結束字元 WriteLineAsyncIn 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() 或使用語言建構,例如 using (在 C# 中) 或 Using (在 Visual Basic 中)。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 類別的新執行個體。Initializes a new instance of the StringWriter class.

StringWriter(IFormatProvider)

使用指定的格式控制項,初始化 StringWriter 類別的新執行個體。Initializes a new instance of the StringWriter class with the specified format control.

StringWriter(StringBuilder)

初始化 StringWriter 類別的新執行個體,這個執行個體可將資源寫入指定的 StringBuilderInitializes a new instance of the StringWriter class that writes to the specified StringBuilder.

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.

欄位

CoreNewLine

儲存這個 TextWriter 所使用的新行字元。Stores the newline characters used for this TextWriter.

(繼承來源 TextWriter)

屬性

Encoding

取得寫入輸出的 EncodingGets the Encoding in which the output is written.

FormatProvider

取得控制格式設定的物件。Gets an object that controls formatting.

(繼承來源 TextWriter)
NewLine

取得或設定目前 TextWriter 所使用的行結束字元字串。Gets or sets the line terminator string used by the current TextWriter.

(繼承來源 TextWriter)

方法

Close()

關閉目前的 StringWriter 和基礎資料流。Closes the current StringWriter and the underlying stream.

Close()

關閉目前寫入器並釋放任何與寫入器相關聯的系統資源。Closes the current writer and releases any system resources associated with the writer.

(繼承來源 TextWriter)
CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(繼承來源 MarshalByRefObject)
Dispose()

釋放由 TextWriter 物件使用的所有資源。Releases all resources used by the TextWriter object.

(繼承來源 TextWriter)
Dispose(Boolean)

釋放 StringWriter 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the StringWriter and optionally releases the managed resources.

DisposeAsync()

以非同步方式釋放由 TextWriter 物件使用的所有資源。Asynchronously releases all resources used by the TextWriter object.

(繼承來源 TextWriter)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Flush()

清除目前寫入器的所有緩衝區,並造成任何緩衝資料都寫入基礎裝置。Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

(繼承來源 TextWriter)
FlushAsync()

以非同步的方式清除目前寫入器的所有緩衝區,並造成任何緩衝資料都寫入基礎裝置。Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

FlushAsync()

以非同步的方式清除目前寫入器的所有緩衝區,並造成任何緩衝資料都寫入基礎裝置。Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

(繼承來源 TextWriter)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
GetStringBuilder()

傳回基礎 StringBuilderReturns the underlying StringBuilder.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(繼承來源 MarshalByRefObject)
ToString()

傳回字串,其中包含至今寫入目前 StringWriter 的字元。Returns a string containing the characters written to the current StringWriter so far.

Write(Boolean)

Boolean 值的文字表示寫入文字資料流。Writes the text representation of a Boolean value to the text stream.

(繼承來源 TextWriter)
Write(Char)

將一個字元寫入字串。Writes a character to the string.

Write(Char[])

將字元陣列寫入文字資料流。Writes a character array to the text stream.

(繼承來源 TextWriter)
Write(Char[], Int32, Int32)

將字元子陣列寫入此字串。Writes a subarray of characters to the string.

Write(Decimal)

將十進位值的文字表示寫入文字資料流。Writes the text representation of a decimal value to the text stream.

(繼承來源 TextWriter)
Write(Double)

將 8 位元組浮點數值的文字表示寫入文字資料流。Writes the text representation of an 8-byte floating-point value to the text stream.

(繼承來源 TextWriter)
Write(Int32)

將 4 位元組帶正負號的整數文字表示寫入文字資料流。Writes the text representation of a 4-byte signed integer to the text stream.

(繼承來源 TextWriter)
Write(Int64)

將 8 位元組帶正負號的整數文字表示寫入文字資料流。Writes the text representation of an 8-byte signed integer to the text stream.

(繼承來源 TextWriter)
Write(Object)

呼叫該物件的 ToString 方法,將物件的文字表示寫入文字資料流。Writes the text representation of an object to the text stream by calling the ToString method on that object.

(繼承來源 TextWriter)
Write(ReadOnlySpan<Char>)

將字元範圍的字串表示寫入目前字串。Writes the string representation of a span of chars to the current string.

Write(ReadOnlySpan<Char>)

將字元範圍寫入文字資料流。Writes a character span to the text stream.

(繼承來源 TextWriter)
Write(Single)

將 4 位元組浮點數值的文字表示寫入文字資料流。Writes the text representation of a 4-byte floating-point value to the text stream.

(繼承來源 TextWriter)
Write(String)

將字串寫入目前的字串。Writes a string to the current string.

Write(String, Object)

使用與 Format(String, Object) 方法相同的語意,將格式化字串寫入文字資料流。Writes a formatted string to the text stream, using the same semantics as the Format(String, Object) method.

(繼承來源 TextWriter)
Write(String, Object, Object)

使用與 Format(String, Object, Object) 方法相同的語意,將格式化字串寫入文字資料流。Writes a formatted string to the text stream using the same semantics as the Format(String, Object, Object) method.

(繼承來源 TextWriter)
Write(String, Object, Object, Object)

使用與 Format(String, Object, Object, Object) 方法相同的語意,將格式化字串寫入文字資料流。Writes a formatted string to the text stream, using the same semantics as the Format(String, Object, Object, Object) method.

(繼承來源 TextWriter)
Write(String, Object[])

使用與 Format(String, Object[]) 方法相同的語意,將格式化字串寫入文字資料流。Writes a formatted string to the text stream, using the same semantics as the Format(String, Object[]) method.

(繼承來源 TextWriter)
Write(StringBuilder)

將字串產生器的字串表示寫入目前字串。Writes the string representation of a string builder to the current string.

Write(StringBuilder)

將字串產生器寫入文字資料流。Writes a string builder to the text stream.

(繼承來源 TextWriter)
Write(UInt32)

將 4 位元組不帶正負號的整數文字表示寫入文字資料流。Writes the text representation of a 4-byte unsigned integer to the text stream.

(繼承來源 TextWriter)
Write(UInt64)

將 8 位元組帶不正負號的整數文字表示寫入文字資料流。Writes the text representation of an 8-byte unsigned integer to the text stream.

(繼承來源 TextWriter)
WriteAsync(Char)

以非同步方式將字元寫入字串。Writes a character to the string asynchronously.

WriteAsync(Char)

以非同步方式將字元寫入文字資料流。Writes a character to the text stream asynchronously.

(繼承來源 TextWriter)
WriteAsync(Char[])

以非同步方式將字元陣列寫入文字資料流。Writes a character array to the text stream asynchronously.

(繼承來源 TextWriter)
WriteAsync(Char[], Int32, Int32)

以非同步方式將字元的子陣列寫入字串。Writes a subarray of characters to the string asynchronously.

WriteAsync(Char[], Int32, Int32)

以非同步方式將字元的子陣列寫入文字資料流。Writes a subarray of characters to the text stream asynchronously.

(繼承來源 TextWriter)
WriteAsync(ReadOnlyMemory<Char>, CancellationToken)

以非同步方式將字元的記憶體區域寫入字串。Asynchronously writes a memory region of characters to the string.

WriteAsync(ReadOnlyMemory<Char>, CancellationToken)

以非同步方式將字元記憶體區域寫入文字資料流。Asynchronously writes a character memory region to the text stream.

(繼承來源 TextWriter)
WriteAsync(String)

將字串以非同步方式寫入目前的字串。Writes a string to the current string asynchronously.

WriteAsync(String)

以非同步方式將字串寫入至文字資料流。Writes a string to the text stream asynchronously.

(繼承來源 TextWriter)
WriteAsync(StringBuilder, CancellationToken)

以非同步方式將字串產生器的文字表示寫入字串。Asynchronously writes the text representation of a string builder to the string.

WriteAsync(StringBuilder, CancellationToken)

以非同步方式將字串產生器寫入文字資料流。Asynchronously writes a string builder to the text stream.

(繼承來源 TextWriter)
WriteLine()

將行結束字元寫入文字資料流。Writes a line terminator to the text stream.

(繼承來源 TextWriter)
WriteLine(Boolean)

Boolean 值的文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a Boolean value to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Char)

將字元寫入文字資料流,後接行結束字元。Writes a character to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Char[])

將字元的陣列寫入文字資料流,後接行結束字元。Writes an array of characters to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Char[], Int32, Int32)

將字元的子陣列寫入文字資料流,後接行結束字元。Writes a subarray of characters to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Decimal)

將十進位值的文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a decimal value to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Double)

將 8 位元組浮點數值的文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a 8-byte floating-point value to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Int32)

將 4 位元組帶正負號的整數文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a 4-byte signed integer to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Int64)

將 8 位元組帶正負號的整數文字表示寫入文字資料流,後接行結束字元。Writes the text representation of an 8-byte signed integer to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Object)

藉由呼叫該物件上的 ToString 方法,後接行結束字元,將物件的文字表示寫入文字資料流。Writes the text representation of an object to the text stream, by calling the ToString method on that object, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(ReadOnlySpan<Char>)

將字元範圍的文字表示寫入字串,後接行結束字元。Writes the text representation a span of characters to the string, followed by a line terminator.

WriteLine(ReadOnlySpan<Char>)

將字元範圍的文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a character span to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(Single)

將 4 位元組浮點數值的文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a 4-byte floating-point value to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(String)

將字串寫入文字資料流,後接行結束字元。Writes a string to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(String, Object)

使用與 Format(String, Object) 方法相同的語意,將格式化字串和新行寫入文字資料流。Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object) method.

(繼承來源 TextWriter)
WriteLine(String, Object, Object)

使用與 Format(String, Object, Object) 方法相同的語意,將格式化字串和新行寫入文字資料流。Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object, Object) method.

(繼承來源 TextWriter)
WriteLine(String, Object, Object, Object)

使用與 Format(String, Object) 相同的語意,寫出文字資料流中的格式化字串和新行。Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object).

(繼承來源 TextWriter)
WriteLine(String, Object[])

使用與 Format(String, Object) 相同的語意,寫出文字資料流中的格式化字串和新行。Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object).

(繼承來源 TextWriter)
WriteLine(StringBuilder)

將字串產生器的文字表示寫入字串,後接行結束字元。Writes the text representation of a string builder to the string, followed by a line terminator.

WriteLine(StringBuilder)

將字串產生器的文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a string builder to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(UInt32)

將 4 位元組不帶正負號的整數文字表示寫入文字資料流,後接行結束字元。Writes the text representation of a 4-byte unsigned integer to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLine(UInt64)

將 8 位元組不帶正負號的整數文字表示寫入文字資料流,後接行結束字元。Writes the text representation of an 8-byte unsigned integer to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLineAsync()

以非同步方式將行結束字元寫入文字資料流。Asynchronously writes a line terminator to the text stream.

(繼承來源 TextWriter)
WriteLineAsync(Char)

以非同步方式將字元寫入字串,後接行結束字元。Asynchronously writes a character to the string, followed by a line terminator.

WriteLineAsync(Char)

以非同步方式將字元寫入文字資料流,後接行結束字元。Asynchronously writes a character to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLineAsync(Char[])

以非同步方式將字元的陣列寫入文字資料流,後接行結束字元。Asynchronously writes an array of characters to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLineAsync(Char[], Int32, Int32)

以非同步方式將字元的子陣列寫入字串,後接行結束字元。asynchronously writes a subarray of characters to the string, followed by a line terminator.

WriteLineAsync(Char[], Int32, Int32)

以非同步方式將字元的子陣列寫入文字資料流,後接行結束字元。Asynchronously writes a subarray of characters to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken)

以非同步方式將字元的記憶體區域字串表示寫入目前字串,後接行結束字元。Asynchronously writes the string representation of the memory region of characters to the current string, followed by a line terminator.

WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken)

以非同步方式將字元記憶體區域的文字表示寫入文字資料流,後接行結束字元。Asynchronously writes the text representation of a character memory region to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLineAsync(String)

以非同步方式將字串寫入目前字串,後接行結束字元。Asynchronously writes a string to the current string, followed by a line terminator.

WriteLineAsync(String)

以非同步方式將字串寫入文字資料流,後接行結束字元。Asynchronously writes a string to the text stream, followed by a line terminator.

(繼承來源 TextWriter)
WriteLineAsync(StringBuilder, CancellationToken)

以非同步方式將字串產生器的字串表示寫入目前字串,後接行結束字元。Asynchronously writes the string representation of the string builder to the current string, followed by a line terminator.

WriteLineAsync(StringBuilder, CancellationToken)

以非同步方式將字串產生器的文字表示寫入文字資料流,後接行結束字元。Asynchronously writes the text representation of a string builder to the text stream, followed by a line terminator.

(繼承來源 TextWriter)

明確介面實作

IDisposable.Dispose()

如需這個成員的說明,請參閱 Dispose()For a description of this member, see Dispose().

(繼承來源 TextWriter)

擴充方法

ConfigureAwait(IAsyncDisposable, Boolean)

設定如何執行從非同步可處置項目傳回的工作 await。Configures how awaits on the tasks returned from an async disposable are performed.

適用於

另請參閱