How to find if an element of a list is in another list?

前端 未结 5 489
误落风尘
误落风尘 2020-12-29 04:43

I want to know if at least one element in a first list can be found in a second list.

I can see two ways to do it. Let\'s say our lists are:

List<         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 05:14

    This is another way to know if an element of one list exists in another list.

    bool present = List1.Any(t => List2.Any(y => y == t));
    

提交回复
热议问题