Overloads Join(String, String[], Int32, Int32) Concatenates the specified elements of a string array, using the specified separator between each element. Join(String, String[]) Concatenates all the elements of a string array, using the specified sepa…
String.Join大大的方便了我们拼接字符串的处理. 1.普通用法:指定元素间的拼接符号 var ids = new List<int>(); for (int i = 0; i < 10; i++) { ids.Add(i); } var inids = string.Join(",", ids); 输出结果:0,1,2,3,4,5,6,7,8,9 2.特殊场景:在元素上添加符号,例如:一个字符串的数组要作为DB脚本的in的条件,需要加单引号,看看我是怎么做的…
List<string> list = new List<string>(); list.Add("I"); list.Add("Love"); list.Add("You"); string kk = string.Empty; kk = string.Join("-", list); Response.Write(kk); //结果 I-Love-You…