I am trying to construct a LINQ query that will take a list of elements, and based on a comparison between the elements in the list, select the ones that meet a certain criteria. Like this:
var subset = set.SomeLinqQuery((e1,e2) => e1 == e2);
subset now contains all e1 of set where e1 == e2. Any ideas? I originally thought of just having a nested loop, but I realized that there must have been a way to do it in LINQ.
You will need a method to generate the unique pairs of items from the original set. Here’s my implementation of that:
Now you can easily achieve what you wanted: