zl程序教程

您现在的位置是:首页 >  后端

当前栏目

LINQ的Except方法

方法 LinQ except
2023-09-27 14:21:30 时间

在两个集合中,左边集合减去右边集合的元素:

 

source code:

 List<int> a = new List<int>{
                { 3 }, { 5 }, { 7 }
            };

            List<int> b = new List<int> {
                { 5 }, { 6 }, { 9 }
            };

            var result = a.Except(b);

            result.ForEach(delegate (int n)
            {
                WriteLiteral(n + "<br>");
            });