I've got a homework stickler for which I need another set of eyes. The assignment is to create a program that prompts for a Student's name, then iterates through an array of days (String[] days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};) prompting for a number of hours studied each day. Finally, the program is to display the daily average number of hours studied for the week.
I'm stuck with the data entry method:
public void EnterHours()
{
// entry area header
Console.WriteLine("Enter study hours for {0} ", name);
for (int i = 0; i < days.Length; i++)
{
Console.Write("{0}'s study hours: ", days[i]);
string dailyHours = Console.ReadLine();
int.TryParse(dailyHours, out hours[i]); // problematic statement
}
SumHours(hours);
}
Currently, the name variable is a property that's already been set; days is the String[] above, and I've instantiated hours as int[] hours; with the same scope as days. SumHours is another method that accepts int[] hours as a parameter and iterates through the array summing the values.
When I run the program, the console displays
Enter study hours for John Doe
Sunday's study hours:
but no matter what I enter, I end up with a Null Reference Exception. I'm also getting the following warning message:
Warning 1 Field 'Midterm.StudentHour.hours' is never assigned to, and will always have its default value null C:\Users\Dan\Dropbox\_MATC\ITDEV115\Assignments\Midterm\StudentHour.cs 11 15 Midterm
I've tried instantiating hours as int[] hours = new int[7]; but get the same error, so I suspect it's something with the way I'm outputting the parsed integer, but I'm not sure what to look at beyond that to solve the problem. Ideas? Hints?

StudentHourclass,StudentHourclass constructor?int[] hoursyou will get the null reference exception at the TryParse. If you declare asint[] hours = new int[7]then it should work. Do you have a different exception then?Dictionarywould serve good purpose in this application.