主要是将两组数组合到list<T>(泛型)中进行搜索和排序

Example

搜索
对存入泛型中的数据进行搜索和排序(Generic)List<Person> people = new List<Person>();
对存入泛型中的数据进行搜索和排序(Generic)
对存入泛型中的数据进行搜索和排序(Generic)        people.Add(
new Person(50"Fred"));
对存入泛型中的数据进行搜索和排序(Generic)        people.Add(
new Person(30"John"));
对存入泛型中的数据进行搜索和排序(Generic)        people.Add(
new Person(26"Andrew"));
对存入泛型中的数据进行搜索和排序(Generic)        people.Add(
new Person(24"Xavier"));
对存入泛型中的数据进行搜索和排序(Generic)        people.Add(
new Person(5"Mark"));
对存入泛型中的数据进行搜索和排序(Generic)        people.Add(
new Person(6"Cameron"));
对存入泛型中的数据进行搜索和排序(Generic)
);

注:上面代码是搜索年龄下于25,或者 名字中包含“F”字母的记录,注意一定要有return语句不要然会报错!

排序

);

注:上面代码是按年龄升序排序,将p1.age和p2.age位置互换就变成降序排序了
如:
);

相关文章:

  • 2021-12-28
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-01-11
相关资源
相似解决方案