s

C# .net list of string to comma separated string edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 11 March 2021 | 1820

Using LINQ you can convert a list of strings to comma-separated string with just one line of code. Check the sample code below.

Solution

List test = new List { "hello", "world", "this", "is", "a", "test"};
String output = test.Aggregate((a, b) => a   ","   b);
             
                    

Output

hello,world,this,is,a,test