Get specific property from all items from the list

前端 未结 2 364
春和景丽
春和景丽 2020-12-15 04:27

I have list of Contacts:

public class Contact
{
    private string _firstName;
    private string _lastName;
    private int _age;

    /// 
         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 04:52

    public List FirstNames
    {
        get
        {
           return _contactList.Select(C => C.FirstName).ToList();
        }
    }
    

提交回复
热议问题