Join Array to String - CSharp System

CSharp examples for System:Array String

Description

Join Array to String

Demo Code


using System.Text;
using System.Runtime.CompilerServices;
using System.Linq;
using System.Collections.Generic;
using System;//  www.  j  a  va  2 s.c o m

public class Main{

        public static string Join<T>(this T[] arr, string split = ",")
        {
            StringBuilder sb = new StringBuilder(arr.Length * 36);
            for (int i = 0; i < arr.Length; i++)
            {
                sb.Append(arr[i].ToString());
                if (i < arr.Length - 1)
                {
                    sb.Append(split);
                }
            }
            return sb.ToString();
        }
}

Related Tutorials