How to convert ArrayList into string array(string[]) in c#

后端 未结 7 791
无人及你
无人及你 2021-01-03 21:31

How can I convert ArrayList into string[] in C#?

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 22:02

    Another way is as follows.

    System.Collections.ArrayList al = new System.Collections.ArrayList();
    al.Add("1");
    al.Add("2");
    al.Add("3");
    string[] asArr = new string[al.Count];
    al.CopyTo(asArr);
    

提交回复
热议问题