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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -