C# .NET: Create a Comma Delimited string from a List

9/2/2013 3:09:10 AM

The following converts a list of strings into a single comma delimited string using C#.

List<string> names = new List<string>();
names.Add("Chris");
names.Add("Rob");
names.Add("Bruce");
names.Add("Sara");
names.Add("Jenny");

string allnames = string.Join(",", names);

//result: allnames = "Chris,Rob,Bruce,Sara,Jenny"