How to Create Comma Separated Strings from List of Strings in C#?

Below is a sample code snippet that demonstrates how one can easily create the comma separated strings from List<string> in C#.

How to Create Comma Separated Strings from List of Strings in C#?

using System;

using System.Collections.Generic;

using System.Data;

using System.IO;

using System.Linq;

namespace AbundantCode

{

internal class Program

{

// How to Create Comma Seperated Strings from List of Strings in C# ?

private static void Main(string[] args)

{

List<string> Websites = new List<string>() { "Abundantcode", "Abundantcode.com", "www.Abundantcode.com" };

string[] ResultList = Websites.ToArray();

string ResultString = string.Join(",", ResultList.ToArray());

Console.WriteLine(ResultString);

Console.ReadKey();

}

}

}