programming-examples/c-sharp/Files/C# Program to Demonstrate StringReader.cs

31 lines
782 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Demonstrate StringReader
*/
using System;
using System.IO;
class Program
{
const string text = @"Sanfoundry
offers Training and Competency
development programs";
static void Main()
{
using (StringReader reader = new StringReader(text))
{
int count = 0;
string textline;
while ((textline = reader.ReadLine()) != null)
{
count++;
Console.WriteLine("Line {0}: {1}", count, textline);
}
Console.ReadLine();
}
}
}
/*
Line 1 : Sanfoundry
Line 2 : Offers Training and Competency
Line 3 : development programs