英語で読む

次の方法で共有


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 タスクまたは関連する I/O タスクの例を示します。

目的 参照項目
テキスト ファイルを作成します。 方法: テキストのファイルへの書き込み
テキスト ファイルに書き込みます。 方法: テキストのファイルへの書き込み
テキスト ファイルから読み取ります。 方法: ファイルからのテキストの読み取り

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

こちらもご覧ください