说我有:
IList<Person> people = new List<Person>();
Run Code Online (Sandbox Code Playgroud)
person对象具有FirstName,LastName和Gender等属性.
如何将其转换为Person对象的属性列表.例如,到名字列表.
IList<string> firstNames = ???
Run Code Online (Sandbox Code Playgroud)
Dar*_*rio 155
List<string> firstNames = people.Select(person => person.FirstName).ToList();
Run Code Online (Sandbox Code Playgroud)
并与排序
List<string> orderedNames = people.Select(person => person.FirstName).OrderBy(name => name).ToList();
Run Code Online (Sandbox Code Playgroud)
IList<string> firstNames = (from person in people select person.FirstName).ToList();
Run Code Online (Sandbox Code Playgroud)
要么
IList<string> firstNames = people.Select(person => person.FirstName).ToList();
Run Code Online (Sandbox Code Playgroud)