Converting a List<int> to a comma separated string

Viewed 104551

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.

8 Answers

you can use, the System.Linq library; It is more efficient:

using System.Linq;
string str =string.Join(",", MyList.Select(x => x.NombreAtributo));
Related