This blog is moved to
http://amalhashim.wordpress.com

Thursday, June 25, 2009

Comma delimted String from List of String using C#

When you have a list of strings like IList of IEnumerable and you want to convert it to for example a comma separated list you can easily do that with the String.Join method.

List<string> list = new List<string>() { "A" , "B", "C", "D", "E" };
string commaSeparated = String.Join(",", list.ToArray());

The output will be like this:

A,B,C,D,E
This is an easy and clean way to create a delimiter separeated list of strings.

No comments: