Saturday 2 December 2017

C# Program to Read Data from Stream and Cast Data to Chars


Code:

using System;
using System.IO;
public sealed class Program
{
    public static void Main()
    {
        using (Stream s = new FileStream(@"c:\sri\srip.txt", FileMode.Open))
        {
            int read;
            while ((read = s.ReadByte()) != -1)
            {
                Console.Write("{0} ", (char)read);
            }
            Console.ReadLine();
        }
    }
}


Output:

G O O D M O R N I N G


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...