On this line:
s[i].getvals();
..you're attempting to access a
students
-object in the array but there is none yet. The array at this point contains nothing but nulls, so you're getting the null-reference exception here.
I assume the for-loop which you've commented out should look like this:
for (int i = 0; i < s.Length; i++)
s[i] = new students();
(Which then will assign a new
students
-object to each array-index.)
Sidenote: In C#, class names and method names should be "CamelCase" and as one object of
students
represents one student, I suggest to name the class
Student
instead. And the methods:
Display
and
GetVals
or
GetValues
.