当前位置:首页>开发>正文

system.array用于数组排序的方法是

2024-06-27 17:52:30 互联网 未知 开发

system.array用于数组排序的方法是?

system.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 !") } }

最新文章

随便看看