2010-01-08 7 views

Répondre

11

Essayez ceci:

IEnumerable<string> letters = new[] { "a", "b", "c", "d", "e" }; 
string separator = ", "; 
string withSeparator = String.Join(separator, letters.ToArray()); 
string withoutSeparator = String.Join(String.Empty, letters.ToArray()); 

En outre, avec .NET 4.0 il y a une nouvelle surcharge plus simple disponible: String.Join Method (String, IEnumerable<String>) vous pouvez donc ignorer l'appel ToArray().

+1

merci, à la recherche de linq alors que la bonne vieille corde l'a! – Michel

Questions connexes