If you have 2 (or more) lists in C# and you want to check if they have 1 or more values in common then you can use the following LINQ to check.
List<string> colourList1 = new List<string>()
{
"Red",
"Yellow",
"Blue"
};
List<string> colourList2 = new List<string>()
{
"Green",
"Yellow",
"Orange"
};
if (colourList1.Any(x => colourList2.Contains(x)))
{
string message = "Do something";
}
0 Comments