Adding namespaces
First, we need to add a couple of namespaces. To do this, enter the following under using System
near the top of the file:
using System.Linq; using System.Collections.Generic;
Creating the student class and defining fields
Next, we will make a class called Student
. Above the line beginning with public partial class _Default...
, enter the following:
public class Student
Next, to define fields, enter the following between a set of curly braces below this line:
public string Name { get; set; }
So, little properties here, and then let's add one more. Enter the following below this line:
public List<int> Grades;
Here, List<int>
is for the grades of the students, and let's name it Grades
.
Making a list of students
Now, in the next stage, we will make a list of students. To do this, start by entering the following between the set of curly braces after the line that begins with protected void Button1_Click...
:
List<Student> students = new List<Student>
Here, students...