join in c# code example
Example 1: c# join string array
var combined = String.Join(",", new String[]{"a","b"});
Example 2: 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 3: c# object list to joined string
using System.Linq
string.Join(",", people.Select(x => x.surname))
Example 4: c# array.join
String Array...
AB
BC
CD
DE
EF
FG
GH
IJ
Result (after joining) = AB*BC*CD*DE*EF*FG*GH*IJ