I\'ve been searching the difference between Select and SelectMany but I haven\'t been able to find a suitable answer. I need to learn the differenc
One more example how SelectMany + Select can be used in order to accumulate sub array objects data.
Suppose we have users with they phones:
class Phone {
public string BasePart = "555-xxx-xxx";
}
class User {
public string Name = "Xxxxx";
public List Phones;
}
Now we need to select all phones' BaseParts of all users:
var usersArray = new List(); // array of arrays
List allBaseParts = usersArray.SelectMany(ua => ua.Phones).Select(p => p.BasePart).ToList();