LINQ query to find if items in a list are contained in another list

前端 未结 9 468
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 00:14

I have the following code:

List test1 = new List { \"@bob.com\", \"@tom.com\" };
List test2 = new List

        
9条回答
  •  春和景丽
    2020-12-01 00:27

    var output = emails.Where(e => domains.All(d => !e.EndsWith(d)));
    

    Or if you prefer:

    var output = emails.Where(e => !domains.Any(d => e.EndsWith(d)));
    

提交回复
热议问题