What is Select() and SelectMany() in LINQ?
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
Example
public class PhoneNumber
{
public string Number { get; set; }
}
public class Person
{
public IEnumerable
public string Name { get; set; }
}
IEnumerable
IEnumerable
IEnumerable
var directory = people .SelectMany(p => p.PhoneNumbers,
(parent, child) => new { parent.Name, child.Number });