Skip to content

Instantly share code, notes, and snippets.

@genghisjahn
Created August 31, 2013 20:16
Show Gist options
  • Save genghisjahn/6400359 to your computer and use it in GitHub Desktop.
Save genghisjahn/6400359 to your computer and use it in GitHub Desktop.
Uses ConvertAll to map one typed list to another typed list.
List<Person> persons = PersonGenerator.Get();
var humans= new List<Human>();
humans = persons.ConvertAll(p => new Human
{
FirstName = p.Name.Split(' ').FirstOrDefault()
, LastName = p.Name.Split(' ').LastOrDefault()
, BirthDay = p.DOB.ToShortDateString()
, HeightInInches = (short)((Double)p.HeightInCM * 0.393701)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment