Advertisement
Guest User

Untitled

a guest
Apr 10th, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace egyszamjatek
  8. {
  9. class egyszamjatek
  10. {
  11. public struct egyszamjáté_változok
  12. {
  13. public int Marci;
  14. public int Lili;
  15. public int Andi;
  16. public int Tibi;
  17. public int Bence;
  18. public int Anna;
  19. public int Mari;
  20. public int Rita;
  21. public int Gabi;
  22. public string fejlécnév;
  23. }
  24. public static List<egyszamjáté_változok> nevek = new List<egyszamjáté_változok>();
  25. public static egyszamjáté_változok név =new egyszamjáté_változok();
  26.  
  27.  
  28. static void Main()
  29. {
  30.  
  31. StreamReader olvas = new StreamReader("egyszamjatek.txt",Encoding.Default);
  32. string beolvasott_Szöveg;
  33. string fejlécnév;
  34. while (!olvas.EndOfStream)
  35. {
  36.  
  37. beolvasott_Szöveg = olvas.ReadLine();
  38. string[] darabok = beolvasott_Szöveg.Split(' ');
  39. név.Marci = Convert.ToInt32(darabok[0]);
  40. név.Lili = Convert.ToInt32(darabok[1]);
  41. név.Andi= Convert.ToInt32(darabok[2]);
  42. név.Tibi = Convert.ToInt32(darabok[3]);
  43. név.Bence= Convert.ToInt32(darabok[4]);
  44. név.Anna= Convert.ToInt32(darabok[5]);
  45. név.Mari= Convert.ToInt32(darabok[6]);
  46. név.Rita= Convert.ToInt32(darabok[7]);
  47. név.Gabi= Convert.ToInt32(darabok[8]);
  48. név.fejlécnév =darabok[10];
  49. nevek.Add(név);
  50.  
  51. }
  52.  
  53. olvas.Close();
  54. foreach (var item in nevek)
  55. {
  56. Console.WriteLine(item.Marci);
  57. }
  58.  
  59.  
  60. Console.ReadKey();
  61. }
  62.  
  63.  
  64.  
  65.  
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement