c# - Generic List to List of string for single Property -
am having generic list of class student
id name class as properties.
i need convert list<string> name property of list<student> did?
list<student> stud; list<string> str; foreach (var item in stud) { str.add(item.name); } is there easier way can w/o using each ?
thanks
you can use linq select project result:
list<string> str = stud.select(s => s.name).tolist();
Comments
Post a Comment