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

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

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

7条回答
  •  有刺的猬
    2021-01-03 22:04

    using System.Linq;
    
    public static string[] Convert(this ArrayList items)
    {
        return items == null
            ? null
            : items.Cast()
                .Select(x => x == null ? null : x.ToString())
                .ToArray();
    }
    
        

    提交回复
    热议问题