如何在C#中连接两个字符串?
要连接两个字符串,请使用String.Concat方法。
假设您要在C#中连接两个字符串str1和str2,然后将其添加为Concat方法中的参数-
string str3 = string.Concat(str1, str2);
示例
以下是示例-
using System;
class Program {
static void Main() {
string str1 = "Brad";
string str2 = "Pitt";
//Concat字符串
string str3 = string.Concat(str1, str2);
Console.WriteLine(str3);
}
}输出结果
BradPitt
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短