How to join list elements into string in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> list = new List<string>();

            list.Add("c");
            list.Add("c++");
            list.Add("c#");
            list.Add("java");
            list.Add("python");

            string s = string.Join(", ", list.ToArray());
            Console.WriteLine(s);
        }
    }
}


/*
run:
      
c, c++, c#, java, python
  
*/

 



answered Aug 4, 2018 by avibootz

Related questions

1 answer 147 views
1 answer 149 views
1 answer 134 views
1 answer 199 views
1 answer 165 views
1 answer 128 views
1 answer 193 views
...