Check if list contains any of another list

前端 未结 3 2216

I have a list of parameters like this:

public class parameter
{
    public string name {get; set;}
    public string paramtype {get; set;}
    public string          


        
3条回答
  •  情话喂你
    2020-12-02 09:47

    Here is a sample to find if there are match elements in another list

    List nums1 = new List { 2, 4, 6, 8, 10 };
    List nums2 = new List { 1, 3, 6, 9, 12};
    
    if (nums1.Any(x => nums2.Any(y => y == x)))
    {
        Console.WriteLine("There are equal elements");
    }
    else
    {
        Console.WriteLine("No Match Found!");
    }
    

提交回复
热议问题