HOHO,不难吧……HOHO//排序嘛就用 LINQ实现好了 public class Student { public string Name{get;set;} public int Age{get;set;} public Student Clone() { Student s = new Student(); s.Name = this.Name; s.Age = this.Age; } }由于这个Student类里的成员都类似于值字段(string虽然是引用类型但操作方式类似于值类型。
//要排序的话,就这样。 public IOrderedEnumerabled<Student> Sort(List<student> students) { return from c in students order by c.Name select c; }容易吧?LINQ真是个漂亮的东西,效率什么的我不管,呵呵。用起来是真舒服。
public class Student
{
public string Name{get;set;}
public int Age{get;set;} public Student Clone()
{
Student s = new Student();
s.Name = this.Name;
s.Age = this.Age;
}
}由于这个Student类里的成员都类似于值字段(string虽然是引用类型但操作方式类似于值类型。
//要排序的话,就这样。
public IOrderedEnumerabled<Student> Sort(List<student> students)
{
return from c in students order by c.Name select c;
}容易吧?LINQ真是个漂亮的东西,效率什么的我不管,呵呵。用起来是真舒服。