I am really a beginner in c# and encountered this problem which I cannot solve even after spent hours searching the internet. I do not understand why the stack object Grades is always null and everytime i run the application, it throws an exception of "System.NullReferenceException". And when I hover over my mouse on Grades, it says "field 'Student.Grades' is never assigned to and will always have its default value null". I also cannot use "{get;set;}" to access this property. So can anyone tell me why? Many thanks!!!(First time asking question on stack overflow sorry for the bad formatting)
class Student : Person
{
public int studentID { get; set; }
public static int nextID;
public Stack<int> Grades;
public Student(string firstName, string lastName, DateTime birthDate,
string address1, string address2, string city, string state,
string zip, string country)
{
FirstName = firstName;
LastName = lastName;
BirthDate = birthDate;
Address1 = address1;
Address2 = address2;
City = city;
State = state;
Zip = zip;
Country = country;
//track the number of students enrolled
studentID = nextID;
nextID++;
}
}