Linq custom comparer for contains? -
I have 2 lists, I want to compare each element with both lists using LINQ ( Versus using nested loop) but, my needs have not been fulfilled because I need to make custom comparisons. I think a custom quicker is needed, but I do not believe 100%.
I do not think it should be very difficult, but it is not certain what I want for this device. There are 2 different and different types of objects in 2 lists.
Update:
Sorry, if I was not clear. I have 2 lists (or calculators), I can do something like this: What I want to do is something like this:
var matches = myList1 Where (t = & gt; myList2.Something (t)) Where are some custom comparisons, maybe I can override the parity compared to the comparison? I can use
.
But I have to argue for comparison.
Update: I thought about using the IEqualityComparer
but it is set to take the type of T, T and T, Y. There are some common obstacles that I can use to solve this problem. I thought it should be easy / simple.
var matches = myList1 Selectmen (t1 = & gt; myList2.Where (T2 = & gt; T. some (T1));
Inner where
is inside your inner foreach
loop, and after the external SelectMany
results Walking as your external foreach
loop.
You can also do a task to do this for yourself (unused; extensions can not remember the syntax):
Public Fixed IEnumerable & lt; T2 & gt; Multicompore & lieutenant; T1, T2 & gt; (This IEnumerable & lt; T1 & gt; first, IEnumerable & lt; T2 & gt; second, funk & lt; bool, T1, T2 & gt; compare) {Return. first of all. Select (t1 = & gt; second.Where (t2 = & gt; comparer T1, T2))); }
Comments
Post a Comment