Saturday 2 December 2017

C# Program to Demonstrate StringReader


Code:

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();
        }
    }
}


Output:

Line 1 : Sanfoundry
Line 2 : Offers Training and Competency
Line 3 : development programs


More C# Programs:


















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...