Projects each element of a sequence to an IEnumerable
IEnumerable group = new List();
// Select gets a list of lists of phone numbers
IEnumerable> phoneLists = group.Select(g => g.Phones);
// SelectMany flattens nested lists of phone numbers to a single list
List phoneNumbers = group.SelectMany(g => g.Phones).ToList();
public class Phone
{
public string Number { get; set; }
}
public class Member
{
public IEnumerable Phones { get; set; }
}
No comments:
Post a Comment