StringWriter.ToString 方法

定義

傳回字串,其中包含至今寫入目前 StringWriter 的字元。

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

傳回

包含寫入目前 StringWriter 的字元之字串。

範例

此程式代碼範例是建構函式所提供較大範例的 StringWriter(IFormatProvider) 一部分。

Console::WriteLine( "Current date and time using the invariant culture: {0}\n"
"Current date and time using the Algerian culture: {1}", DateTime::Now.ToString(), strWriter->ToString() );
Console.WriteLine(
    "Current date and time using the invariant culture: {0}\n" +
    "Current date and time using the Algerian culture: {1}",
    DateTime.Now.ToString(), strWriter.ToString());
Console.WriteLine( _
    "Current date and time using the invariant culture: {0}" _
    & vbCrLf & _
    "Current date and time using the Algerian culture: {1}", _
    DateTime.Now.ToString(), strWriter.ToString())

備註

下表列出其他一般或相關 I/O 工作的範例。

作法... 請參閱這個主題中的範例…
建立文字檔 作法:將文字寫入檔案
寫入文字檔。 作法:將文字寫入檔案
從文字檔讀取。 作法:讀取檔案中的文字

適用於

另請參閱