Created
September 15, 2018 17:03
-
-
Save tylerlrhodes/010e0a0e726a337df8ffb3d8fdf48ca7 to your computer and use it in GitHub Desktop.
Demo of SelectMany function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace SelectManyExample | |
{ | |
public class BookCase | |
{ | |
public List<string> Books { get; set; } = new List<string>(); | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var BookCases = new List<BookCase> | |
{ | |
new BookCase() | |
{ | |
Books = new List<string>() { "The C Programming Language", "Writing a Compiler in Go", "The Little Schemer" } | |
}, | |
new BookCase() | |
{ | |
Books = new List<string>() { "How Linux Works", "Windows Via C/C++", "Structure and Interpretation of Computer Programs" } | |
}, | |
new BookCase() | |
{ | |
Books = new List<string>() { "Lisp in Small Pieces", "Programming Language Pragmatics", "Algorithms" } | |
} | |
}; | |
var books = BookCases.SelectMany(bc => bc.Books); | |
foreach (var book in books) | |
Console.WriteLine(book); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment