Advertisement
lmohanarun

C# C#

Oct 25th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1.  
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.IO;
  9. namespace Padroes
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. try
  16. {
  17.  
  18.  
  19. // Open the text file using a stream reader.
  20. const string FILENAME = @"Example.txt";
  21.  
  22.  
  23. List<List<int>> data = new List<List<int>>();
  24.  
  25. string inputLine = "";
  26. StreamReader reader = new StreamReader(FILENAME);
  27.  
  28. while ((inputLine = reader.ReadLine()) != null)
  29. {
  30. inputLine = inputLine.Trim();
  31. if (inputLine.Length > 0)
  32. {
  33. List<int> inputArray = inputLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
  34.  
  35. data.Add(inputArray);
  36. Console.WriteLine(inputLine);
  37. }
  38. }
  39. }
  40.  
  41. catch (Exception e)
  42. {
  43. Console.WriteLine("The file could not be read:");
  44. Console.WriteLine(e.Message);
  45. }
  46.  
  47. Console.ReadKey();
  48. }
  49. }
  50. }
  51.  
  52. 1 2 9
  53.  
  54. 1 2 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement