diff --git a/ICD.Common.Utils/Extensions/StringExtensions.cs b/ICD.Common.Utils/Extensions/StringExtensions.cs index b82d1d7..1bcf158 100644 --- a/ICD.Common.Utils/Extensions/StringExtensions.cs +++ b/ICD.Common.Utils/Extensions/StringExtensions.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Text.RegularExpressions; using ICD.Common.Properties; @@ -142,6 +143,46 @@ namespace ICD.Common.Utils.Extensions Math.Min(chunkSize, extends.Length - (i * chunkSize)))); } + /// + /// Joins the strings in the enumerable. + /// + /// + /// + public static string Join([NotNull] this IEnumerable extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + return extends.Join(string.Empty); + } + + /// + /// Joins the strings in the enumerable. + /// + /// + /// + /// + public static string Join([NotNull] this IEnumerable extends, string delimiter) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + StringBuilder builder = new StringBuilder(); + bool isFirst = true; + + foreach (string item in extends) + { + if (!isFirst) + builder.Append(delimiter); + + builder.Append(item); + + isFirst = false; + } + + return builder.ToString(); + } + /// /// Removes whitespace from the string. ///