I'm just trying to return true if one list contains the name / value from list2:
This will be my structure:
public class TStockFilterAttributes { public String Name { get; set; } public String Value { get; set; } } List<TStockFilterAttributes> List1 = new List<TStockFilterAttributes>(); List<TStockFilterAttributes> List2 = new List<TStockFilterAttributes>();
This should return true:
List1.Add(new TStockFilterAttributes { Name = "Foo", Value = "Bar" }); List2.Add(new TStockFilterAttributes { Name = "Foo", Value = "Bar" });
But this will return false, because Name && The value does not match:
List1.Add(new TStockFilterAttributes { Name = "Foo", Value = "Bar" }); List2.Add(new TStockFilterAttributes { Name = "Foo", Value = "Foo" });
Each list can contain many different values, and I just need to know if any of List1 matches any of List2.
I tried using:
return List1.Intersect(List2).Any();
but this seems to return false in all cases, I assume it is because I keep the class in List, and not a simple int / string?
c # linq
webnoob
source share