public class TopClass
{
public static void Main()
{
string contents = "My content\r\nHi there";
using (StringReader reader = new StringReader(contents))
{
int lineNo = 0;
string line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine("Line#{0}: {1}", ++lineNo, line);
}
}
}
}
---------------
OUTPUT:-
Line#1: My content
Line#2: Hi there
-----------------------------------
{
public static void Main()
{
string contents = "My content\r\nHi there";
using (StringReader reader = new StringReader(contents))
{
int lineNo = 0;
string line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine("Line#{0}: {1}", ++lineNo, line);
}
}
}
}
---------------
OUTPUT:-
Line#1: My content
Line#2: Hi there
-----------------------------------
No comments:
Post a Comment