StringReader.ReadLine メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > StringReader.ReadLine メソッドの意味・解説 

StringReader.ReadLine メソッド

基になる文字列から 1 行読み取ります。

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
解説解説

このメソッドは、TextReader.ReadLine メソッドオーバーライドます。

行は、キャリッジ リターン ("\r")、ライン フィード ("\n")、またはキャリッジ リターンライン フィード組み合わせ末尾付いた一連の文字として定義されます。しかし、返される文字列には、行の終端を示すキャリッジ リターンライン フィード含まれません。基になる文字列末尾到達している場合戻り値null 参照 (Visual Basic では Nothing) になります

現在のメソッドOutOfMemoryExceptionスローした場合、基になる文字列内のリーダー位置読み取ることができた文字数分だけ進みますが、既に内部 ReadLine バッファ読み取られ文字破棄されます。文字列内のリーダー位置変更できないため、既に読み取られ文字復元できません。もう一度アクセスするには、StringReader を再初期化する必要がありますこのような状況回避し信頼性の高いコード作成するには、Read メソッド使用して割り当て済みバッファ読み取った文字格納する必要があります

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

使用例使用例

このコード例は、StringReader クラストピック取り上げているコード例一部分です。

' 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)
// 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.
   String^ aLine;
String^ aParagraph;
StringReader^ strReader = gcnew StringReader( textReaderText );
while ( true )
{
   aLine = strReader->ReadLine();
   if ( aLine != nullptr )
   {
      aParagraph = String::Concat( aParagraph, aLine,  " " );
   }
   else
   {
      aParagraph = String::Concat( aParagraph,  "\n" );
      break;
   }
}

Console::WriteLine(  "Modified text:\n\n{0}", aParagraph );

// From textReaderText, create a continuous paragraph 
// with two spaces between each sentence.
String aParagraph = "";
String aLine;
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);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からStringReader.ReadLine メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からStringReader.ReadLine メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からStringReader.ReadLine メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

StringReader.ReadLine メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



StringReader.ReadLine メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS