I have Cell
objects which contain a List<int>
called PossibleValues
. I'm trying to find a way to get a list of cells in which all members have matching PossibleValues. I currently have:
foreach (var cell in group)
{
var cellsWithMatchingPossibleValues = group.Where(c => c.PossibleValues == cell.PossibleValues);
}
Unfortunately this isn't working, I suspect my linq statement isn't comparing the contents of PossibleValues, but instead comparing a reference of some kind, so that even in the case where both lists are composed of 3 and nothing else, cellsWithMatchingPossibleValues ends up only containing one cell, although I'm not certain, or sure how to get around that.
To formalise the question: How can I return objects which contain Lists based on the those lists matching?