Assume
class Person
{
string FirstName;
string LastName;
int Age;
}
and a list
List<Person> listPerson;
Possible ways to get a list of only first names of all the person in this list
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think your easiest way will be
List<string> firstNames = listPerson.Select(p => p.FirstName).ToList()But in order to do this, you’ll need to make the properties public.