第一种,匹配俩个集合中相同的值

  var listA = new List<int> { 2, 5, 6, 8, 23, 56, 4 };
            var listB = new List<int> { 1, 6, 9, 11, 34, 29, 5, 23, 4 };
           var C= listA.Intersect(listB);
           foreach (var item in C)
           {
               Console.WriteLine(item);
           }
           Console.ReadLine();

第二种,拷贝

 var listA = new List<int> { 2, 5, 6, 8, 23, 56, 4 };
            var listB = new List<int>();

            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, listA);
                ms.Position = 0;
                listB = (List<int>)bf.Deserialize(ms);
            }        

参考别人的,具体是谁 我也忘记了

相关文章:

  • 2023-03-11
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-01-21
猜你喜欢
  • 2021-08-06
  • 2021-11-17
  • 2022-02-27
  • 2021-12-22
  • 2021-08-17
  • 2022-12-23
  • 2022-03-04
相关资源
相似解决方案