C #: Comment convertir une liste d’objects en une liste d’une propriété unique de cet object?

Dis que j’ai:

IList people = new List(); 

Et l’object personne a des propriétés comme FirstName, LastName et Gender.

Comment puis-je convertir cela en une liste de propriétés de l’object Person. Par exemple, à une liste de prénoms.

 IList firstNames = ??? 

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

Et avec le sorting

 List orderedNames = people.Select(person => person.FirstName).OrderBy(name => name).ToList(); 
 IList firstNames = (from person in people select person.FirstName).ToList(); 

Ou

 IList firstNames = people.Select(person => person.FirstName).ToList(); 
 firstNames = (from p in people select p=>p.firstName).ToList(); 
 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace TestProject { public partial class WebForm3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SampleDataContext context = new SampleDataContext(); List l = new List(); var qry = from a in context.tbl_employees where a.Gender=="Female" orderby a.Salary ascending select new Employee() { ID=a.Id, Fname=a.FName, Lname=a.Lname, Gender=a.Gender, Salary=a.Salary, DepartmentId=a.DeparmentId }; l= qry.ToList(); var e1 = from emp in context.tbl_employees where emp.Gender == "Male" orderby emp.Salary descending select emp; GridView1.DataSource = l; GridView1.DataBind(); } } public class Employee { public Int64 ID { get; set; } public Ssortingng Fname { get; set; } public Ssortingng Lname { get; set; } public Ssortingng Gender { get; set; } public decimal? Salary { get; set; } public int? DepartmentId { get; set; } } } 
 using System.Collections.Generic; using System.Linq; IList people = new List(); IList firstNames = people.Select(person => person.FirstName).ToList();