1.string集合转int集合

//string类型的集合
List<string> tempStr = new List<string>() { "21", "232", "12" };

//转为int类型的集合
List<int> tempNum=tempStr.Select(x=>int.Parse(x)).ToList();

2. 根据一个集合的字段去重另一个集合

var rmrList = rmrList.Where((a, i) => rmrList.FindIndex(f => f.wx_userid == a.wx_userid) == i).ToList();

 List<int> listA = new List<int> {1,2,3,5,7,9};

  List<int> listB = new List<int> {13,4,17,29,2};

 

  listA.AddRange(listB );把集合A.B合并
  List<int> Result = listA.Union(listB).ToList<int>();          //剔除重复项 
  List<int> Result = listA.Concat(listB).ToList<int>();        //保留重复项

  listA.BinarySearch("1");//判断集合中是否包含某个值.如果包含则返回0

 

 

相关文章:

  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
猜你喜欢
  • 2021-11-04
  • 2022-03-05
  • 2022-12-23
  • 2021-09-04
  • 2021-08-17
  • 2021-08-01
相关资源
相似解决方案