var combined = String.Join(",", new String[]{"a","b"});
// a,b
var arr1 = new int[]{1,2,3,4,5,6};
var arr2 = new int[]{7,8,9,0};
var joinedArray = arr1.Concat(arr2);
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);
}
}
public static string Join(string separator, params obj[] array);
object[] array = {"Hello", 12345, 786};
string s1 = string.Join(", ", array);
using System.Linq;
namespace Program
{
public class Program
{
string[] cLangs = { "Langs","C", "C++", "C#" };
// String join will just join the array with a comma and a whitespace
// Using Linq, the skip method will skip x (called count in the parameter) number elements you tell it to
Console.WriteLine(string.Join(", ", cLangs.Skip(1).ToArray())); // Output: C, C++, C#
}
}
List<string> names = new List<string>() { "John", "Anna", "Monica" };
var result = String.Join(", ", names.ToArray());