I'm using these following classes to send to an object forward but somehow I'm getting an Null Reference Exception at "obj.course[0].age = 16;"
class Student{
int Id {get; set;}
List<Course> course {get; set;}
}
class Course{
int age;
List<Subjects> subjects {get; set;}
}
class Subjects{
int history{get; set;}
int biology {get; set;}
int physics {get; set;}
}
//--------------------------------------------------
Student obj = new Student();
obj.Id = 1;
obj.course[0].age = 16;
obj.course[0].Subjects[0].history= 30;
obj.course[0].Subjects[0].biology = 45;
obj.course[0].Subjects[0].physics = 55;