见过不少人、经过不少事、也吃过不少苦,感悟世事无常、人心多变,靠着回忆将往事串珠成链,聊聊感情、谈谈发展,我慢慢写、你一点一点看......
1、使用 List<T>.Sort 方法与自定义比较器
public class Person{public string Name { get; set; }public int Age { get; set; }}public class PersonComparer : IComparer<Person>{public int Compare(Person x, Person y){// 按年龄升序排序return x.Age.CompareTo(y.Age);// 或更复杂的排序逻辑}}class Program{static void Main(){List<Person> people = new List<Person>{new Person { Name = "A", Age = 15 },new Person { Name = "B", Age = 25 },new Person { Name = "C", Age = 35 }&

最低0.47元/天 解锁文章
746

被折叠的 条评论
为什么被折叠?



