我收到这个错误...
指数超出范围。必须是非负数且小于集合的大小。
参数名称:index
.
在指定位置的代码中。
List<int>[] tetangga = new List<int>[this.observasi];
for (int i = 0; i < this.observasi; i++)
{
tetangga[i] = new List<int>();
for (int j = 0; j < this.observasi; j++)
{
if (tableWeight[i, j] > 0)
{
tetangga[i].Add(j);
}
}
}
this.dataTable.ColumnCount = 2;
this.dataTable.Columns[0].HeaderCell.Value = "REGION";
this.dataTable.Columns[1].HeaderCell.Value = "REGION NEIGHBOR";
this.dataTable.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
this.dataTable.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
this.dataTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
int jlhRow = 0;
for (int i = 0; i < this.observasi; i++)
{
jlhRow = jlhRow + tetangga[i].Count;
}
this.dataTable.RowCount = jlhRow;
int row = 0;
for (int k = 0; k < this.observasi; k++)
{
this.dataTable[0, row].Value = this.nameRegion[k]; // <-- error occurs here
for (int l = 0; l < tetangga[k].Count; l++)
{
this.dataTable[1, row].Value = this.nameRegion[tetangga[k][l]];
row++;
}
}
谁能向我解释为什么?