using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
string name = "";
int score = 0;
string[,] Name_Score = {{"吴松","89"}, {"钱东宇","90"}, {"伏晨", "98"}, {"陈陆","56"}, {"周蕊","60"},{"林日鹏","91"}, {"何昆","93"},{"关欣","85"}};
for (int i = 0; i < Name_Score.GetLongLength(0); i++ )
{
if (int.Parse(Name_Score[i,1]) > score)
{
name = Name_Score[i,0];
score = int.Parse (Name_Score[i,1]);
}
}
Console.WriteLine("分数最高的是{0}, 分数是{1}", name, score);
}
}
}
改进:可以用object作为数组,这样就可以直接比较就不用将string转换为int了