这样可行吗
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
class Program
{
public class Student
{
public string name { get; set; }
public int score { get; set; }
}
static void Main(string[ ] args)
{
List<Student> students = new List<Student>
{
new Student() { name="吴松", score=89},
new Student() { name="钱东宇", score=90},
new Student() { name="伏晨",score=98},
new Student() { name="陈陆",score=56},
new Student() { name="周蕾",score=60},
new Student() { name="林日鹏",score=91},
new Student() { name="何昆",score=93},
new Student() { name="关欣", score=85}
};
int HighScore = 0;
string winnerName = "";
foreach (Student v in students)
{
if (v.score > HighScore)
{
HighScore = v.score;
winnerName = v.name;
}
}
Console.WriteLine("分数最高的是{0},分数是{1}", winnerName, HighScore);
}
}
}