public void TwoDArrayShowINDatagridview(string[,] arr)
{
DataTable dt = new DataTable();
for (int column = 0; column < arr.GetLength(1); column++)
dt.Columns.Add(arr[0, column], typeof(string)); //新增列;列名显示二维数组的第一个元素-标题
for (int row = 1; row < arr.GetLength(0); row++) //填充行数据
{
DataRow dr = dt.NewRow();
for (int column = 0; column < arr.GetLength(1); column++)
dr[column] = arr[row, column];
dt.Rows.Add(dr);
}
this.dataGridView.DataSource = dt;
}