repl.it
@kironroy/

studentList

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
  • Student.cs
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;


namespace Collections
{

    class Program
    {
        static void Main()
        {
          List<Student> students = new List<Student>
           {
               new Student() { Name = "Sally", GradeLevel = 3},
               new Student() { Name = "Bob", GradeLevel = 3},
               new Student() { Name = "Sally", GradeLevel = 2}
           };

            students.Sort();

            foreach (Student student in students)
            {
                Console.WriteLine($"{student.Name} is in grade { student.GradeLevel}");
            }
        }
    }
}