Rather than using an extra string object and the Substring method, this is better (also uses the fact that StringBuilder methods are composable):
public static string Intersperse<T> (IEnumerable<T> enumerable, string delimiter) { StringBuilder sb = new StringBuilder (); foreach (T item in enumerable) { if (item == null) continue; sb.Append (item).Append (delimiter); } sb.Length = sb.Length - delimiter.Length; return sb.ToString(); }
Recent comments
4 weeks 3 days ago
7 weeks 9 hours ago
7 weeks 4 days ago
8 weeks 9 hours ago
8 weeks 9 hours ago
8 weeks 9 hours ago
9 weeks 5 days ago
10 weeks 5 days ago
12 weeks 6 days ago
12 weeks 6 days ago