Advertisement
stambeto09

TextFileReader

Jan 21st, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4.  
  5. namespace _01.TextFileReader
  6. {
  7. class TextFileReader
  8. {
  9. static void Main()
  10. {
  11. StreamReader reader = new StreamReader("TextFileForReading.txt",false);
  12.  
  13. using (reader)
  14. {
  15. string line = reader.ReadLine();
  16. int lineNumber = 0;
  17. while (line!=null)
  18. {
  19. lineNumber++;
  20. if (lineNumber%2!=0)
  21. {
  22. Console.WriteLine("Line {0}: {1}", lineNumber, line);
  23. }
  24.  
  25. line = reader.ReadLine();
  26.  
  27. }
  28.  
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement