问问题没见过这么牛叉的结贴率为0
没时间写答案了delegate

解决方案 »

  1.   

    List<Student> lst= new List<Student>();
    List<T>.Sort(IComparer<T>)
    public class StudentComparer : IComparer<Student>
    {
    public enum CompareType
    {
    Name,
    Age,
    Grade
    }
    private CompareType type;
    public StudentComparer(CompareType type)
    {
    this.type = type;
    }
    public int Compare(Student x, Student y)
    {
    switch(this.type)
    {
    case CompareType.Name:
    return x.Name.CompareTo(y.Name);
    case CompareType.Age:
    return x.Age.CompareTo(y.Age);
    default:
    return x.Grade.CompareTo(y.Grade);
    }
    }
    }
      

  2.   

    实现 IComparer接口,然后sort
    你也可以用for再加些算法来整。