其实就是让你写一个类,实现IComparable接口,再通过调用Sort方法对该类的实例(一维数组)排序。
class Student:IComparable
{
private string name;
private int score;
public int CompareTo(object obj)
{
Student _obj = obj as Student;
if (_obj != null)
{
return this.score.CompareTo(_obj.score);
}
else
throw new ArgumentException("Object is not a Student !");
}
}
你上网上查询IComparable 网上就有答案
请问你这是在干什么?