Given a list of strings, what is the best method for concatenating these strings into a comma separated list with no comma at the end. (VB.NET or C#) (Using either StringBuilder
Would you believe there's a class in the .NET framework which provides this functionality?
public static string ListToCsv(List list)
{
CommaDelimitedStringCollection commaStr = new CommaDelimitedStringCollection();
list.ForEach(delegate(T item)
{
commaStr.Add(item.ToString());
});
return commaStr.ToString();
}