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

Murugan Andezuthu Dharmaratnam | 11 March 2021 | 58

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