Created
August 31, 2013 20:16
-
-
Save genghisjahn/6400359 to your computer and use it in GitHub Desktop.
Uses ConvertAll to map one typed list to another typed list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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