C#中用数组实例化一个类,如何给数组每个成员的字段进行赋值

class student
{
public int chinese; //student类有三个字段
public int math;
public int english;
}
class Program
{
static void Main(string[] args)
{
student[] a= new student[10];
a[0].chinese = 1;
}
如上所示,意图给a[0]的字段进行赋值,结果运行时报错"未将对象引用设置到对象的实例。"请高手们看看哪错了,或者有什么办法实现该功能。

student[] a= new student[10];
a[0] = new student();
a[0].chinese = 1;
或者:
student[] a= new student[10]{new student(),new student(),new student(),new student(),new student(),new student(),new student(),new student(),new student(),new student()};
a[0].chinese = 1;

温馨提示:答案为网友推荐,仅供参考
相似回答