array類中對一維數組排序的方法?
其實就是讓你寫一個類,實現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 !");