我不明白为什么我会收到此错误,因为我的多维数组应该可以正常工作,但由于列出的错误,它在这种情况下无法正常工作......我非常沮丧。
错误是:Wrong number of indices inside []; expected 2
这就是我所拥有的:
public static void DisplayTopScore(string username, double score)
{
string[] highscores = System.IO.File.ReadAllLines(@"C:\Users\Public\TestFolder\WriteLines2.txt");
string[,] Temphighscores = new string[10, 2];
string[] TempScoresToSplit;
int counter=0;
foreach (string highScore in highscores)
{
TempScoresToSplit = highScore.Split(' ');
Temphighscores[counter][0]= TempScoresToSplit[0];
Temphighscores[counter][1]= TempScoresToSplit[1];
counter++;
}
}
}
它说错误数量的索引的地方在这 2 行:
Temphighscores[counter][0]= TempScoresToSplit[0];
Temphighscores[counter][1]= TempScoresToSplit[1];