From the course: Advanced C#: Functional Programming Patterns

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Join with SelectMany

Join with SelectMany

- [Instructor] SelectMany is also useful for joining similar lists. So I'll start by talking about the data that I have. I have setA and setB. setA is the numbers two, three, and four. setB is the numbers five, six, and seven, and I want to perform a Cartesian join on these, so I want the number two paired with five, the number two paired with six, the number two paired with seven, and so on. In order to get the data out of both of these sets, I need to use Select. If I use Select here on A, I can select out the three items that are in there, and then I can nest that and call setB.Select, and I get the three items there. But the problem is the same problem we had in the previous example, where the callers ended up in a separate collection. I'll show you what I mean. I'm trying to build up this string. A is equal to this value, comma B is equal to this value. What do I have? I have three items. That's the…

Contents