Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have List<Person> object obj containing variables like 'Name', 'Surname', etc.
List<Person>
obj
How can I fetch just List of all Names using lambda expression only? (i.e x->x...)
List
Select(x => x.Name)
Use Select:
Select
var x = obj.Select(x => x.Name)
Add a comment
You can do it like this:
List<Person> persons = new List<Person>(); //init list var names = persons.Select(x=>x.Name);
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
Select(x => x.Name). msdn.microsoft.com/en-US/library/bb548891(v=vs.110).aspx