int[] list = new [] {3, 99, 6};
string s = string.Join(",", list.Select(x => x.ToString()).ToArray());
Edit, C# 4.0
With C# 4.0, there is another overload of string.Join
, which finally allows passing an IEnumerable<string>
or IEnumerable<T>
directly. There is no need to create an Array, and there is also no need to call ToString()
, which is called implicitly:
string s = string.Join(",", list);
With explicit formatting to string:
string s = string.Join(",", list.Select(x => x.ToString(/*...*/));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…