本帖最后由 Always. 于 2013-9-18 09:59 编辑
string[] lines = txtScore.Lines;
string maxname = " ";
int maxscore =-1;
foreach (string line in lines)
{
string[]remove=line.Split('=');
string name = remove[0];
string strscore = remove[1];
int score = Convert.ToInt32(strscore);
if (score > maxscore)
{
maxscore = score;
maxname = name;
}
}
MessageBox.Show(string.Format("第一名是{0},最高分为{1}", maxname, maxscore));
问题代码是: string strscore = remove[1]; 显示是索引超出了数组的界限 file:///D:\2509743941\Image\U))VO0DGTHX(4NNW_63$~5F.jpgfile:///D:\2509743941\Image\U))VO0DGTHX(4NNW_63$~5F.jpg
|