How to convert ArrayList to array in C#

1 Answer

0 votes
using System;
using System.Collections;

class Program
{
    static void Main() {
        ArrayList list = new ArrayList(){"c#", "c", "c++",  "php"};

        string[] arr = list.ToArray(typeof(string)) as string[];

        foreach (string s in arr) {
            Console.WriteLine(s);
        }
    }
}




/*
run:

c#
c
c++
php

*/

 



answered Sep 10, 2020 by avibootz

Related questions

1 answer 114 views
1 answer 162 views
1 answer 185 views
185 views asked Jan 28, 2019 by avibootz
2 answers 255 views
255 views asked Feb 9, 2017 by avibootz
1 answer 173 views
1 answer 118 views
118 views asked Apr 20, 2020 by avibootz
7 answers 504 views
504 views asked Sep 11, 2019 by avibootz
...