// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; namespace E { public class Program { public static void Test1(string fnm) { using(StreamReader sr = new StreamReader(fnm)) { string line; while((line = sr.ReadLine()) != null) { Console.WriteLine("=" + line); } } } public static void Test2(string fnm) { using(StreamReader sr = new StreamReader(fnm)) { string line; while(!sr.EndOfStream) { line = sr.ReadLine(); Console.WriteLine("=" + line); } } } private const string FNM = @"C:\tst.txt"; public static void Test(string s) { using(StreamWriter sw = new StreamWriter(FNM)) { sw.Write(s); } Test1(FNM); Test2(FNM); } public static void Main(string[] args) { Test("A\r\nBB\r\nCCC"); Test("A\r\nBB\r\nCCC\r\n"); } } }