I have an int array with the value 3,99,6. How do i convert the array into the string 3,99,6
with linq?
views:
38answers:
2
+4
A:
string s = string.Join(", ", list.Select(x => x.ToString()).ToArray());
Stefan Steinegger
2010-07-09 09:40:19
+3
A:
Stefan's solution is correct, and pretty much required for .NET 3.5. In .NET 4, there's an overload of String.Join
which takes an IEnumerable<string>
so you can use:
string s = string.Join(",", list.Select(x => x.ToString());
Jon Skeet
2010-07-09 09:43:57
*very* good to know when i switch to 4
acidzombie24
2010-07-09 09:47:12