How to create a comma separated string from a list of string in C#?
We can covert a List of string to a comma separated string using built instring.Join
extension method.Example
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<string> strings = new List<string>{"1","2","testing"};
string joined = string.Join(", ", strings);
Console.WriteLine(joined);
}
}
Output
1, 2, testing