c#如何实现以下效果?
- C# code
PosGroup.Lane.Row[m].Col[n].Layer[h].Pos.PosState = Convert.ToInt32(ds1.Tables[0].Rows[i]["Pos_State"]);
[解决办法]
把 for(int m=0;m<=IRow;m++) 循环整个换成下面的代码,看哪行出的错
- C# code
var lane = PosGroup.Lane;var row = lane.Row;for (int m = 0; m <= IRow; m++){ PosGroup.Lane.Row[m] = new TRow(); for (int n = 0; n <= ICol; ICol++) { PosGroup.Lane.Row[m].Col[n] = new TCol(); for (int h = 0; h <= ILayer; h++) { PosGroup.Lane.Row[m].Col[n].Layer[h] = new TLayer(); PosGroup.Lane.Row[m].Col[n].Layer[h].Pos.PosState = Convert.ToInt32(ds1.Tables[0].Rows[i]["Pos_State"]); PosGroup.Lane.Row[m].Col[n].Layer[h].Pos.Zone_ID = Convert.ToInt32(ds1.Tables[0].Rows[i]["Zone_ID"]); PosGroup.Lane.Row[m].Col[n].Layer[h].Pos.PID = Convert.ToInt32(ds1.Tables[0].Rows[i]["PID"]); PosGroup.Lane.Row[m].Col[n].Layer[h].Pos.HasSetValue = true; } }}