Skip to content

Instantly share code, notes, and snippets.

@tylerlrhodes
Created September 15, 2018 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerlrhodes/010e0a0e726a337df8ffb3d8fdf48ca7 to your computer and use it in GitHub Desktop.
Save tylerlrhodes/010e0a0e726a337df8ffb3d8fdf48ca7 to your computer and use it in GitHub Desktop.
Demo of SelectMany function
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