How to convert an array of strings to List in C#

1 Answer

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

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = new string[]
            {
                "c#",
                "java",
                "c++",
                "c"
            };

            List<string> list = new List<string>(arr);

            foreach (string s in list)
                Console.WriteLine(s);
        }
    }
}

/*
run:

c#
java
c++
c

*/

 



answered Jan 6, 2017 by avibootz

Related questions

1 answer 172 views
1 answer 206 views
1 answer 157 views
2 answers 132 views
1 answer 79 views
4 answers 290 views
290 views asked Sep 22, 2020 by avibootz
...