110,533
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
//已设置textBox1.Multiline=true;
string[] str = textBox1.Lines;
List<int[]> rowList = new List<int[]>();
for (int i = 0; i < str.Length; i++)
{
int[] row = str[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select<string, int>(item => Convert.ToInt32(item)).ToArray();
rowList.Add(row);
}
int rowCount = rowList.Max(row => row[0]) + 1;
int columnCount = rowList.Max(row => row[1]) + 1;
int[,] datas = new int[rowCount, columnCount];
for (int i = 0; i < rowList.Count; i++)
{
datas[rowList[i][0], rowList[i][1]] = rowList[i][2];
}
}
这个代码是用逗号(,)来分割的,可以改成其他。