C#: How to convert a list of objects to a list of a single property of that object?

List<string> firstNames = people.Select(person => person.FirstName).ToList();

And with sorting

List<string> orderedNames = people.Select(person => person.FirstName).OrderBy(name => name).ToList();

Leave a Comment