C# 字符串Join方法示例
以下示例在字符串数组的每个元素之间插入逗号和空格 (", ")。
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { string name = "Onitroad.com"; string add = " PHP JAVA"; string add2 = " Learning world"; string[] sentence = new String[] { name, add, add2 }; string result = String.Join(", ", sentence); Console.WriteLine("Join Results: " + result); Console.ReadLine(); } } }
当您需要在字符串数组的每个元素之间插入分隔符 (String) 以生成单个连接字符串时,Join 方法很有用。
日期:2020-04-11 22:50:25 来源:oir作者:oir