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.

Flatten with SelectMany

Flatten with SelectMany

- [Instructor] The next concept we're looking at is called bind, and you'll find it goes under different names depending on the language. It's called bind in Haskell. In Scala, it's called flat map. The concept itself is called flattening in C# and it's implemented in LINQ with select many or continue with. There's another use of bind, which is for joining together multiple lists, and we'll look at that later. In this video, we're looking at the flattening aspects of bind by using select many. The idea is we're going to flatten a multidimensional set into a single set, or another way of saying that is we're going to select values from a nested collection. And my nested collection lives inside this class called brand. Here it is. This class represents a company's brand. So I have the brand name and I have a list of string that represents the colors of this brand. On line 21, I am instantiating the…

Contents