2014-12-05 24 views
1

我需要將IEnumerable<string> emails轉換爲逗號分隔的string。 的iEnumerable實際上是Hashset<string>與電子郵件,我需要生成字符串與','IEnumerable <string>以逗號分隔的字符串

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

我該怎麼辦呢分隔的電子郵件,而無需使用循環

+0

可能[從IList 或IEnumerable ]創建逗號分隔列表的副本(http://stackoverflow.com/questions/799446/creating -a-comma-separated-list-from-iliststring-or -ienumerablestring) – 2014-12-05 17:57:27

+0

不,我不想創建一個列表,但字符串 – Yakov 2014-12-06 06:47:09

+0

你甚至按照鏈接?標題中的措詞可能有點不幸,但這完全是同一個問題,C#2.0,3.5和4.0+ – 2014-12-06 10:58:03

回答

8

您可以使用String.Join

string result = String.Join(", ", emails);