Tag Archives: Convert a list of string to comma separated string C#

Convert a list of string to comma separated string C#.

Convert a list of string to Comma Separated String. String.join method is used to concatenate a list of string, Using a specified separator between each string.
Syntax : String.Join(string Separator, String[] Values);
Example :

static void Main(string[] args)
{           
    List<string> listStrings = new List<string>() { "C#", "Asp.Net", "SQL Server", "PHP", "Angular" };
    string CommaSeparateString = GenerateCommaSeparateStringFromList(listStrings);
    Console.Write(CommaSeparateString);
    Console.ReadKey();
}

private static string GenerateCommaSeparateStringFromList(List<string> listStrings)
{
    return String.Join(",", listStrings);            
}


Comma Separate String

Comma Separate String