StringWriter.Write メソッド

定義

文字列にデータを書き込みます。

オーバーロード

Write(Char[], Int32, Int32)

文字列に文字配列の一部を書き込みます。

Write(String)

現在の文字列に文字列を書き込みます。

Write(StringBuilder)

文字列ビルダーの文字列形式を現在の文字列に書き込みます。

Write(Char)

文字列に文字を書き込みます。

Write(ReadOnlySpan<Char>)

文字のスパンの文字列形式を現在の文字列に書き込みます。

Write(Char[], Int32, Int32)

文字列に文字配列の一部を書き込みます。

public:
 override void Write(cli::array <char> ^ buffer, int index, int count);
public override void Write (char[] buffer, int index, int count);
override this.Write : char[] * int * int -> unit
Public Overrides Sub Write (buffer As Char(), index As Integer, count As Integer)

パラメーター

buffer
Char[]

データの書き込み元の文字配列。

index
Int32

データの読み取りを開始する、バッファー内の位置。

count
Int32

書き込む文字の最大数。

例外

buffernullです。

index または count が負の値です。

(index + count)>buffer. Length.

ライターが閉じています。

このコード例は、コンストラクターに対して提供されるより大きな例の StringWriter() 一部です。

// Use the three overloads of the Write method that are 
// overridden by the StringWriter class.
strWriter->Write( "file path characters are: " );
strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length );
strWriter->Write( Char::Parse( "." ) );
// Use the three overloads of the Write method that are
// overridden by the StringWriter class.
strWriter.Write("file path characters are: ");
strWriter.Write(
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
strWriter.Write('.');
' Use the three overloads of the Write method that are 
' overridden by the StringWriter class.
strWriter.Write("file path characters are: ")
strWriter.Write( _
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length)
strWriter.Write("."C)

注釈

このメソッドは、TextWriter.Write をオーバーライドします。

このメソッドは、 count から 位置 indexからデータの文字を書StringWriterbufferき込みます。

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

目的 参照項目
テキスト ファイルを作成します。 方法: テキストのファイルへの書き込み
テキスト ファイルに書き込みます。 方法: テキストのファイルへの書き込み
テキスト ファイルから読み取ります。 方法: ファイルからのテキストの読み取り
ファイルにテキストを追加します。 方法: ログ ファイルを開いて情報を追加する

File.AppendText

FileInfo.AppendText
ファイルのサイズを取得します。 FileInfo.Length
ファイルの属性を取得します。 File.GetAttributes
ファイルの属性を設定します。 File.SetAttributes
ファイルが存在するかどうかを確認します。 File.Exists
バイナリ ファイルから読み取ります。 方法: 新しく作成されたデータ ファイルに対して読み書きする
バイナリ ファイルに書き込みます。 方法: 新しく作成されたデータ ファイルに対して読み書きする

こちらもご覧ください

適用対象

Write(String)

現在の文字列に文字列を書き込みます。

public:
 override void Write(System::String ^ value);
public override void Write (string value);
public override void Write (string? value);
override this.Write : string -> unit
Public Overrides Sub Write (value As String)

パラメーター

value
String

書き込む文字列。

例外

ライターが閉じています。

このコード例は、StringWriter クラスのために提供されている大規模な例の一部です。

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

    // Bypass the spaces between sentences.
    strReader.Read();
    strReader.Read();
}
convertedCharacter = Convert.ToChar(intCharacter)
If convertedCharacter = "."C Then
    strWriter.Write("." & vbCrLf & vbCrLf)

    ' Bypass the spaces between sentences.
    strReader.Read()
    strReader.Read()

注釈

このメソッドは、TextWriter.Write をオーバーライドします。

指定した文字列が の場合は null、何も書き込まれます。

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

目的 参照項目
テキスト ファイルを作成します。 方法: テキストのファイルへの書き込み
テキスト ファイルに書き込みます。 方法: テキストのファイルへの書き込み
テキスト ファイルから読み取ります。 方法: ファイルからのテキストの読み取り
ファイルにテキストを追加します。 方法: ログ ファイルを開いて情報を追加する

File.AppendText

FileInfo.AppendText
ファイルのサイズを取得します。 FileInfo.Length
ファイルの属性を取得します。 File.GetAttributes
ファイルの属性を設定します。 File.SetAttributes
ファイルが存在するかどうかを確認します。 File.Exists
バイナリ ファイルから読み取ります。 方法: 新しく作成されたデータ ファイルに対して読み書きする
バイナリ ファイルに書き込みます。 方法: 新しく作成されたデータ ファイルに対して読み書きする

こちらもご覧ください

適用対象

Write(StringBuilder)

文字列ビルダーの文字列形式を現在の文字列に書き込みます。

public:
 override void Write(System::Text::StringBuilder ^ value);
public override void Write (System.Text.StringBuilder? value);
override this.Write : System.Text.StringBuilder -> unit
Public Overrides Sub Write (value As StringBuilder)

パラメーター

value
StringBuilder

文字列に書き込む文字列ビルダー。

適用対象

Write(Char)

文字列に文字を書き込みます。

public:
 override void Write(char value);
public override void Write (char value);
override this.Write : char -> unit
Public Overrides Sub Write (value As Char)

パラメーター

value
Char

書き込む文字。

例外

ライターが閉じています。

このコード例は、コンストラクターに対して提供されるより大きな例の StringWriter() 一部です。

// Use the three overloads of the Write method that are 
// overridden by the StringWriter class.
strWriter->Write( "file path characters are: " );
strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length );
strWriter->Write( Char::Parse( "." ) );
// Use the three overloads of the Write method that are
// overridden by the StringWriter class.
strWriter.Write("file path characters are: ");
strWriter.Write(
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
strWriter.Write('.');
' Use the three overloads of the Write method that are 
' overridden by the StringWriter class.
strWriter.Write("file path characters are: ")
strWriter.Write( _
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length)
strWriter.Write("."C)

注釈

このメソッドは、TextWriter.Write をオーバーライドします。

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

目的 参照項目
テキスト ファイルを作成します。 方法: テキストのファイルへの書き込み
テキスト ファイルに書き込みます。 方法: テキストのファイルへの書き込み
テキスト ファイルから読み取ります。 方法: ファイルからのテキストの読み取り
ファイルにテキストを追加します。 方法: ログ ファイルを開いて情報を追加する

File.AppendText

FileInfo.AppendText
ファイルのサイズを取得します。 FileInfo.Length
ファイルの属性を取得します。 File.GetAttributes
ファイルの属性を設定します。 File.SetAttributes
ファイルが存在するかどうかを確認します。 File.Exists
バイナリ ファイルから読み取ります。 方法: 新しく作成されたデータ ファイルに対して読み書きする
バイナリ ファイルに書き込みます。 方法: 新しく作成されたデータ ファイルに対して読み書きする

こちらもご覧ください

適用対象

Write(ReadOnlySpan<Char>)

文字のスパンの文字列形式を現在の文字列に書き込みます。

public:
 override void Write(ReadOnlySpan<char> buffer);
public override void Write (ReadOnlySpan<char> buffer);
override this.Write : ReadOnlySpan<char> -> unit
Public Overrides Sub Write (buffer As ReadOnlySpan(Of Char))

パラメーター

buffer
ReadOnlySpan<Char>

文字列に書き込む文字のスパン。

適用対象