Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to initialize list with 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 78 views
1 answer 39 views
39 views asked Oct 1, 2022 by avibootz
1 answer 53 views
1 answer 22 views
1 answer 43 views
...