简体   繁体   中英

how to use string.join to join value from an object array?

I have an array of object eg:

MyObject[] objs;

and within MyObject it contains a string property,

object[0].stringValue

If I want to join the whole array of objects by their stringValue , how can I do it?

string.Join(",",objs.Select(w=>w.stringValue))

Do you mean to use string.Join to concatenate a property from multiple MyObject objects into one single string?

Then:

string str = string.Join(",", objs.Select(x => x.SomeProperty));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM