次の方法で共有


StringWriter.ToString メソッド

現在の StringWriter に書き込まれた文字を格納している文字列を返します。

Overrides Public Function ToString() As String
[C#]
public override string ToString();
[C++]
public: String* ToString();
[JScript]
public override function ToString() : String;

戻り値

現在の StringWriter に書き込まれた文字を格納している文字列。

解説

その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。

実行するタスク 参考例があるトピック
テキスト ファイルを作成する。 ファイルへのテキストの書き込み
テキスト ファイルに書き込む。 ファイルへのテキストの書き込み
テキスト ファイルから読み取る。 ファイルからのテキストの読み取り

使用例

[Visual Basic, C#, C++] 次のコード例は、 System.IO.StringWriter.StringWriter2 コンストラクタの例の一部です。

 
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())

[C#] 
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());

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

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

StringWriter クラス | StringWriter メンバ | System.IO 名前空間 | 入出力操作 | ファイルからのテキストの読み取り | ファイルへのテキストの書き込み