Friday, April 24, 2015

Adding object

Thanks BonnieB, as you adviced me, I created a Student[] object in the Course class and do cs.Students = myStudents, Students is the Student[] object in the Course class and myStudents is the array of five students. It's seem that it's work fine but when I compile it, the program throw me the following exception message at the first line:


   A System.NullReferenceException was throw.

   Object reference not set to an instance of an object.

  // Instantiation of five students

 1   myStudents[0].sFirstName = "Anders";  // Error line

2   myStudents[0].sLastName = "Hejlsberg";

 3   myStudents[0].sBirthDate = new DateTime(1960, 12 , 24, 10, 35, 40);

     ........................ And so on

what's really happen ?

No comments:

Post a Comment