C# 尝试初始化内部类数组时的NPE

C# 尝试初始化内部类数组时的NPE,c#,class,computer-science,internal,C#,Class,Computer Science,Internal,我试图在类内部创建一个内部类,然后将其初始化为第一个值=0 我有这个 class Vehicle { internal class AGVSteps { public double X { get; set; } public double Y { get; set; } } private AGVSteps[] steps ; public AGVSteps [] St

我试图在类内部创建一个内部类,然后将其初始化为第一个值=0 我有这个

class Vehicle {
         internal class AGVSteps {
             public double X { get; set; }
             public double Y { get; set; }
         }

         private AGVSteps[] steps ;
         public AGVSteps [] Steps {
             get { return this.steps; }
         }

        public Vehicle() { //constructor
            this.steps = new AGVSteps[2000];
            this.steps[0].X = 0; //CRASHES HERE
            MessageBox.Show(this.steps[0].X + "");
            for (int i = 0; i < 2000; i++) {
               // this.steps[i].X = -1;
                //this.steps[i].Y = -1;
            }
        }

}
class车辆{
内部类AGVSteps{
公共双X{get;set;}
公共双Y{get;set;}
}
私有AGVSteps[]步骤;
公共AGVSteps[]步骤{
获取{返回this.steps;}
}
公共车辆(){//constructor
this.steps=新AGVSteps[2000];
this.steps[0].X=0;//在此崩溃
MessageBox.Show(this.steps[0].X+“”);
对于(int i=0;i<2000;i++){
//这个.steps[i].X=-1;
//这个.steps[i].Y=-1;
}
}
}

知道吗?我有个NPE错误。谢谢

steps
AGVSteps
对象的容器。您需要初始化
AGVSteps
本身

this.steps = new AGVSteps[2000];
for (int i = 0; i < steps.Length; i++) {
    steps[i] = new AGVSteps();
}
this.steps=newagvsteps[2000];
for(int i=0;i