String.Join only works on strings. I initally thought I’d create an extension method for List<T> that would use string builder to return a built string for any type of list. I don’t think StringBuilder would help much here after thinking about it. We would still have to call ToString on all the non String objects. Here is what I think is a good solution. I don’t know if it’s the best.

var result = string.Join(“,”, myList.Select(x => x.ToString()).ToArray());



No Responses Yet to “Comma seperated lists in C#”  

  1. No Comments Yet

Leave a Reply