In LINQ, Select() and SelectMany() are projection operators. The use of a Select() operator is to select a value from a collection whereas the use of SelectMany() operator is to select values from a group of collection, i.e. a nested collection.

BY Best Interview Question ON 22 Apr 2020


public class PhoneNumber
    public string Number { get; set; }
public class Person
   public IEnumerable PhoneNumbers { get; set; }
   public string Name { get; set; }
IEnumerable people = new List();
IEnumerable> phoneLists = people.Select(p => p.PhoneNumbers);
IEnumerable phoneNumbers = people.SelectMany(p => p.PhoneNumbers);
var directory = people .SelectMany(p => p.PhoneNumbers,
(parent, child) => new { parent.Name, child.Number });