zoukankan      html  css  js  c++  java
  • .net string类型集合转int集合

    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

     

  • 相关阅读:
    System 类的使用
    StringBuffer 与 StringBuilder类的使用
    String 类 的 使用
    多线程
    音乐播放
    数据库
    表示图编辑
    UITextView(2)
    UITextView
    tarBar
  • 原文地址:https://www.cnblogs.com/longbky/p/10242665.html
Copyright © 2011-2022 走看看