Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IEnumerable<string> to comma separated string

I need to convert the IEnumerable<string> emails to comma separated string. The iEnumerable is actually Hashset<string> with emails, I need to generate string with emails separated by ','

[email protected], [email protected], [email protected]

how can I do it without using loop

like image 546
Yakov Avatar asked Apr 06 '26 11:04

Yakov


1 Answers

You can use String.Join:

string result = String.Join(", ", emails);
like image 138
Tim Schmelter Avatar answered Apr 08 '26 23:04

Tim Schmelter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!