Greetings,
could you enlighten me what may cause a NullReferenceException in the code below? I tried to create an array of my own ("student") class, but in vain it seems...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class student
{
public string name;
public byte note;
}
class Program
{
static void Main(string[] args)
{
student[] students = new student[5];
Random rnd = new Random();
for (int i = 0; i < students.Length; i++)
{
students[i].note = (byte)rnd.Next(1, 6);
students[i].name = "aaa";
}
}
}
}
|
Thanx if you have a cure.