Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp19
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. List<Student> students = new List<Student>();
  15.  
  16. Student s1 = new Student(1, "Hector", 33);
  17. Student s2 = new Student(2, "Vaios", 22);
  18. Student s3 = new Student(3, "Chrysanthi", 20);
  19. Student s4 = new Student(4, "Panagiotis", 18);
  20. Student s5 = new Student(5, "Manolis", 21);
  21.  
  22. students.Add(s1);
  23. students.Add(s2);
  24. students.Add(s3);
  25. students.Add(s4);
  26. students.Add(s5);
  27.  
  28. foreach (var item in students)
  29. {
  30. Console.WriteLine(item.Name);
  31. }
  32.  
  33.  
  34.  
  35.  
  36. }
  37. }
  38.  
  39. class Student
  40. {
  41. public int Id;
  42. public string Name;
  43. public int Age;
  44.  
  45. public Student(int id, string name, int age)
  46. {
  47. Id = id;
  48. Name = name;
  49. Age = age;
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement