string[] lines = txt成绩.Lines;
string maxName = "";
int maxScore = -1;
foreach (string line in lines)
{
string[] strs = line.Split('=');
string name=strs[0];
string strscore = strs[1];
int score = Convert.ToInt32(strscore);
if (maxScore < score)
{
maxName = name;
maxScore = score;
}
}
MessageBox.Show(string.Format("{0}是第一名,成绩是{1}",maxName,maxScore));
求解文中lforeach中的line含义以及Split,琢磨了一下,还是无解,望各位不吝赐教。 |