C# string combine code example
Example 1: c# array.join
using System;
public class Demo {
public static void Main(string[] args) {
string[] strArr = {"AB", "BC", "CD", "DE", "EF", "FG", "GH", "IJ" };
Console.WriteLine("String Array...");
foreach(string s in strArr) {
Console.WriteLine(s);
}
string str = string.Join("*", strArr);
Console.WriteLine("Result (after joining) = " + str);
}
}
Example 2: c# string concatenation
string userName = "<Type your name here>";
string dateString = DateTime.Today.ToShortDateString();
string str = "Hello " + userName + ". Today is " + dateString + ".";
System.Console.WriteLine(str);
str += " How are you today?";
System.Console.WriteLine(str);
Example 3: c# Add or Concatenate Strings In C#
string str1 = "ppp";
string strRes = str1.Insert(2, "bbb");
Console.WriteLine(strRes.ToString());