1. 程式人生 > >C# List<string>和ArrayList用指定的分隔符分隔成字符串

C# List<string>和ArrayList用指定的分隔符分隔成字符串

light arp 字符串 元素 logs arraylist pre brush type

原文地址:https://www.cnblogs.com/ahwwmb/p/4166707.html

串聯字符串數組的所有元素,其中在每個元素之間使用指定的分隔符

            List<string> arr = new List<string>();
            arr.Add("好玩1");
            arr.Add("好玩1");
            arr.Add("好玩1");
            string str = string.Join(",", arr.ToArray());

            ArrayList arr1 = new ArrayList();
            arr1.Add("好玩1");
            arr1.Add("好玩2");
            arr1.Add("好玩3");
            string str1 = string.Join(",", arr1.ToArray(typeof(string)) as string[]);

  

C# List<string>和ArrayList用指定的分隔符分隔成字符串