I'm new to C# and I tried making a "Student" class that takes the student name and few other things. I have a problem at taking student name as I get an exception when typing the name as input.
In declaration,
public class Student
{
public string studentName;// this one
public long studentID;
public int score1;
...etc
}
then I have inside Main:
Student[] student = new Student[N];
// the N is determined by a previous block of code.
for (int i = 0; i < N; i++)
{
check = false; // ignore this one.
Console.WriteLine("Student {0}", i + 1);
Console.Write("\t \t Name: ");
string input = Console.ReadLine();
student[i].studentName = input;
// I get an exception at that last line, after typing whatever string.I feel like I've done something horribly wrong.
}
Thanks :)