標籤:列表 dex collect 指定 bsp com readline http log
join函數定義如下:
// 串聯類型為 System.String 的 System.Collections.Generic.IEnumerable<T> 構造集合的成員,其中在每個成員之間使用指定的分隔字元。 public static string Join(string separator, IEnumerable<string> values); // 串聯字串集合的成員,其中在每個成員之間使用指定的分隔字元。 public static string Join<T>(string separator, IEnumerable<T> values); // 串聯對象數組的各個元素,其中在每個元素之間使用指定的分隔字元。 public static string Join(string separator, params object[] values); // 串聯字串數組的所有元素,其中在每個元素之間使用指定的分隔字元。 public static string Join(string separator, params string[] value); // 串聯字串數組的指定元素,其中在每個元素之間使用指定的分隔字元。 public static string Join(string separator, string[] value, int startIndex, int count);
比如,我們常用“ , "來把一個數組給串聯起來。
這裡展示一個執行個體,分別把一個數組和一個List集合給串聯起來。
static void Main(string[] args) { string[] param = new string[] { "小紅", "小明", "小張", "小劉" }; string param1 = string.Join(",", param); Console.WriteLine(param1); List<string> list = new List<string>(); list.Add("列表1"); list.Add("列表2"); list.Add("列表3"); list.Add("列表4"); string param2 = string.Join(",", list); Console.WriteLine(param2); Console.ReadLine(); }
結果如下:
數組,集合分割函數,join()