在本文中,我们将讨论如何在C#中连接两个字符串。
在C#中添加两个字符串
字符串类的Concat方法连接一个或者多个字符串和对象以及所有字符串和对象的组合。
在C#中串联字符串示例
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { int number = -123; bool b = false; Object numberObject = number; object boolObject = b; string author = "Onitroad .com"; Object[] objs = new Object[] { 555, 444, 999 }; Console.WriteLine("Concatenate 1: {0}", String.Concat(numberObject)); Console.WriteLine("Concatenate multiple: {0}", String.Concat(numberObject, boolObject, author)); Console.WriteLine("Concatenate an array: {0}", String.Concat(objs)); Console.ReadLine(); } } }
日期:2020-04-11 22:50:17 来源:oir作者:oir