private void Test()
        {
            List<string> lsA = new List<string>();
            lsA.Add("A");
            lsA.Add("B");
            lsA.Add("C");
            lsA.Add("D");

            List<string> lsB = new List<string>();
            lsB.Add("C");
            lsB.Add("D");
            lsB.Add("E");
            lsB.Add("F");


            List<string> lsC = new List<string>();
            lsC.Add("D");
            lsC.Add("G");
            lsC.Add("H");

            IEnumerable<string> lstNew = null;
            lstNew = lsA.Intersect(lsB, StringComparer.OrdinalIgnoreCase);

            lstNew = lstNew.Intersect(lsC, StringComparer.OrdinalIgnoreCase);
            //也可以连着写,如下
            //   lstNew = lsA.Intersect(lsB, StringComparer.OrdinalIgnoreCase).Intersect(lsC, StringComparer.OrdinalIgnoreCase);


            //下面这种方式也可以
            // IEnumerable<string> lsIntersect = Enumerable.Intersect(lsA, lsB);

            
            string str = string.Empty;
            if (lstNew != null && lstNew.Count<string>() > 0)
            {
                foreach (string c in lstNew)
                {
                    str += c;
                }
            }
            MessageBox.Show(str);
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2021-08-04
  • 2022-12-23
  • 2021-06-11
  • 2021-06-03
猜你喜欢
  • 2021-12-25
  • 2021-04-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
相关资源
相似解决方案