i think this question has been asked before but i havent been able to deduce a clear answer. I am trying to find the best way (or a way) to intersect two completely different ienumerable collections.
class A:
- int z1
- int z2
- int z3
- string z4
class B:
- int j5
- int j6
- T j7
- T j8
- string j9
..I want to intersect List<A> with List<B> on z2 == j6.
can this be done?
The question doesn’t really make sense – what would the result type be? Intersections have to be performed on two sequences of the same type. It sounds like you don’t so much want an intersection between two sets, as a filter of the first sequence based on possible values of z2. For example:
Or possibly as Gabe suggests, you want a join. For example:
That will give you all pairings of values from the two lists which match on z2/j6.