using System;
using System.Collections.ObjectModel;
using System.Linq;
namespace TextTest
{
public class Students:Collection此处的collection总是显示缺少类型,请问缺少的是什么类型
{
public double AverageScore()
{
return Items.Average(s=>s.Score);
}
public int MaxScore()
{
return Items.Max(s=>s.Score);
}
public Student MaxScoreStudent()
{
int maxScore=MaxScore();
return Items.First(s=>s.Score==maxScore);
}
public int MaxScoreStudentId()
{
return Items.IndexOf(MaxScoreStudent());
}
public int MinScore()
{
return Items.Min(s=>s.Score);
}
public Student MinScoreStudent()
{
int minScore=MinScore();
return Items.First(s=>s.Score==minScore);
}
public int MinScoreStudentId()
{
int minScore=MinScore();
return Items.IndexOf(MinScoreStudent());
}
}
public class Student
{
private string _Id;
public string Id
{
get {return _Id;}
set {_Id=value;}
}
private int _Score;
public int Score
{
get{return _Score;}
set{_Score =value;}
}
}
}
最大值和最小值可以运用比较的方法啊,得出最大值最小值下标就出来了,平均分直接算
应该把学生成绩和姓名什么的考虑成对象,然后通过排序,得到最大最小
using System.Collections;
加上试试看