C# - Simplest way to turn a List of strings into a comma separated string - updated 2020

What you are looking for is most likely the static method Join from the string class. It is a very smooth way to create a comma separated string. You can easily separate by any delimiter you wish. It can be used like below:

var someList = new List<string>
{
   "A", "B","C"
};
var commaSeparatedString = string.Join(",", someList); //result will be "A,B,C"

If you need this in many places you can create a small extension method for this. This is sometimes preferred over creating private methods everywhere:

public static string ToCommaSeperatedString(this IEnumerable<string> list)
{
   return string.Join(",", list);
}

And it can be used like below:

var commaSeparatedString = someList.ToCommaSeperatedString();

That is in my book the easiest way to turn a list of strings into a comma separated string. If you disagree or found this helpful, please let me know in the comments down below!