我正在尝试将二维字符串数组转换为二维 int 数组:
int[][] inner = new int[4][];
string[][] arr = new string[4][]
{
new string[] {"11"},
new string[] {"12"},
new string[] {"21"},
new string[] {"22"}
};
for (int i = 0; i < arr.Length; i++)
{
string name = string.Join(".", arr[i]);
for (int j = 0; j < name.Length; j++)
{
inner[i][j] = Convert.ToInt32(name.Substring(j,1));
}
}
但我得到以下异常:
你调用的对象是空的
在:
inner[i][j] = Convert.ToInt32(name.Substring(j,1));