Guest User

Untitled

a guest
May 16th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace lolz
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. const string f = "hemmelig.txt";
  14.  
  15. // 1
  16. // Declare new List.
  17. List<string> lines = new List<string>();
  18.  
  19. // 2
  20. // Use using StreamReader for disposing.
  21. using (StreamReader r = new StreamReader(f))
  22. {
  23. // 3
  24. // Use while != null pattern for loop
  25. string line;
  26. while ((line = r.ReadLine()) != null)
  27. {
  28. // 4
  29. // Insert logic here.
  30. // ...
  31. // "line" is a line in the file. Add it to our List.
  32. lines.Add(line);
  33. }
  34. }
  35.  
  36. // 5
  37. // Print out all the lines.
  38. foreach (string s in lines)
  39. {
  40.  
  41. }
  42. Console.ReadKey();
  43. }
  44. }
  45. }
Add Comment
Please, Sign In to add comment