C# – Converting List to Comma Separated String

c++collections

Is there a way to take a List and convert it into a comma separated string?

I know I can just loop and build it, but somehow I think some of you guys a more cool way of doing it?

I really want to learn these types of 'tricks', so please explain or link to the docs on the method you use.

Best Answer

List<int> list = ...;
string.Join(",", list.Select(n => n.ToString()).ToArray())