StringReader.ReadLine メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As StringReader Dim returnValue As String returnValue = instance.ReadLine
基になる文字列の次の行。基になる文字列の末尾に到達した場合は null 参照 (Visual Basic では Nothing)。


このメソッドは、TextReader.ReadLine メソッドをオーバーライドします。
行は、キャリッジ リターン ("\r")、ライン フィード ("\n")、またはキャリッジ リターンとライン フィードの組み合わせが末尾に付いた一連の文字として定義されます。しかし、返される文字列には、行の終端を示すキャリッジ リターンやライン フィードは含まれません。基になる文字列の末尾に到達している場合、戻り値は null 参照 (Visual Basic では Nothing) になります。
現在のメソッドが OutOfMemoryException をスローした場合、基になる文字列内のリーダーの位置は読み取ることができた文字数分だけ進みますが、既に内部 ReadLine バッファに読み取られた文字は破棄されます。文字列内のリーダーの位置は変更できないため、既に読み取られた文字は復元できません。もう一度アクセスするには、StringReader を再初期化する必要があります。このような状況を回避し、信頼性の高いコードを作成するには、Read メソッドを使用して、割り当て済みのバッファに読み取った文字を格納する必要があります。
その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。
File.AppendText FileInfo.AppendText | |
FileInfo.Length | |
File.GetAttributes | |
File.SetAttributes | |

このコード例は、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);

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からStringReader.ReadLine メソッドを検索する場合は、下記のリンクをクリックしてください。

- StringReader.ReadLine メソッドのページへのリンク