C# StringReader ReadLine
Description
StringReader ReadLine
Reads a line of characters from
the current string and returns the data as a string.
Syntax
StringReader.ReadLine
has the following syntax.
public override string ReadLine()
Returns
StringReader.ReadLine
method returns The next line from the current string, or null if the end of the string is reached.
Example
This code example is part of a larger example provided for the StringReader class.
//from w ww . ja v a2 s .c o m
using System;
using System.IO;
public class MainClass{
public static void Main(String[] argv){
string aLine, aParagraph = null;
StringReader strReader = new StringReader("this \nis \na \ntest from java2s.com");
while(true)
{
aLine = strReader.ReadLine();
if(aLine != null)
{
aParagraph = aParagraph + aLine + " ";
}
else
{
aParagraph = aParagraph + "\n";
break;
}
}
Console.WriteLine("Modified text:\n\n{0}", aParagraph);
}
}