How to convert list to array in C#

1 Answer

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

class Program
{
    static void Main() {
        List<string> list = new List<string>() {"c#", "c", "c++",  "php"};

        string[] arr = list.ToArray();
 
        foreach (string s in arr) {
            Console.WriteLine(s);
        }
    }
}



/*
run:

c#
c
c++
php

*/

 



answered Sep 10, 2020 by avibootz

Related questions

1 answer 199 views
1 answer 102 views
1 answer 130 views
1 answer 164 views
164 views asked Aug 16, 2021 by avibootz
4 answers 320 views
320 views asked Sep 22, 2020 by avibootz
1 answer 148 views
148 views asked Jul 30, 2018 by avibootz
...