public static string SPrint <T>(this T[] array, string delimiter, Func <T, string> stringFunc) { using (PooledStringBuilder sb = PooledStringBuilder.Get()) { T item; string s; for (int idx = 0; idx < array.Length; idx++) { if (idx > 0) { sb.Append(delimiter); } item = array[idx]; sb.Append(item == null ? "null" : stringFunc == null ? item.ToString() : stringFunc(item)); } s = sb.ToString(); return(s); } }
public static string SPrint <T>(this IList <T> list, string delimiter, Func <T, string> stringFunc) { using (PooledStringBuilder sb = PooledStringBuilder.Get()) { T item; string s; for (int idx = 0; idx < list.Count; idx++) { if (idx > 0) { sb.Append(delimiter); } item = list[idx]; sb.Append(item == null ? "null" : stringFunc == null ? item.ToString() : stringFunc(item)); } s = sb.ToString(); return(s); } }