I have the following two lists:
IEnumerable<bool> a = True True True False
List<bool> b = True True False False
I need to create another list that shows true if the element of list a and list b match. List a and b will always be populated and have the same number of elements. So for example the output would be:
List<bool> c = True True False True
Is there a simple way I can do this? Would I have to use LINQ? I guess I could do it be iterating through an array but I am hoping there’s a simpler way.
If you’re using .NET 4, you can use LINQ through
IEnumerable.Zipto “zip” the two lists together into a third result list. Zip operates on coordinating elements in both lists to produce a third list.The second parameter is a function defining what you want to do with each pair of elements.