Example

 using System; using System.IO; using System.Text; namespace Samples { public class StreamReaderSample { public static void Main() { string s = "streamreader.txt"; using(StreamReader sr = new StreamReader(s)) { DisplayInformationAboutStream(sr); Console.WriteLine(sr.ReadLine()); Console.WriteLine((Char)sr.Peek()); Console.WriteLine(sr.ReadLine()); } Byte[] bytes = {72, 101, 108, 108, 111, (byte) '\n', 87, 111, 114, 108, 100}; MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length); using(StreamReader sr = new StreamReader(ms)) { DisplayInformationAboutStream(sr); Console.WriteLine(sr.ReadLine()); Console.WriteLine((Char)sr.Peek()); Console.WriteLine(sr.ReadLine()); } } public static void DisplayInformationAboutStream( StreamReader ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.