StringReader(String) コンストラクター

定義

指定した文字列から読み取る StringReader クラスの新しいインスタンスを初期化します。

public:
 StringReader(System::String ^ s);
public StringReader(string s);
new System.IO.StringReader : string -> System.IO.StringReader
Public Sub New (s As String)

パラメーター

s
String

StringReaderを初期化する文字列。

例外

s パラメーターはnull

このコード例は、 StringReader クラスに提供されるより大きな例の一部です。

// 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);
' 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)

注釈

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

これを行うには... このトピックの例を参照してください...
テキスト ファイルを作成します。 方法: ファイルにテキストを書き込む
テキスト ファイルに書き込む。 方法: ファイルにテキストを書き込む
テキスト ファイルから読み取る。 方法: ファイルからテキストを読み取る
ファイルにテキストを追加します。 方法: ログ ファイルを開いて追加する

File.AppendText

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

適用対象

こちらもご覧ください