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

后端 未结 7 735
无人及你
无人及你 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<object>()
                .Select(x => x == null ? null : x.ToString())
                .ToArray();
    }
    
    0 讨论(0)
提交回复
热议问题