예제 #1
0
        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join <T>(char separator, IEnumerable <T> values)
        {
            var sb = new Utf8ValueStringBuilder(true);

            try
            {
                var isFirst = true;
                foreach (var item in values)
                {
                    if (!isFirst)
                    {
                        sb.Append(separator);
                    }
                    else
                    {
                        isFirst = false;
                    }
                    sb.Append(item);
                }

                return(sb.ToString());
            }
            finally
            {
                sb.Dispose();
            }
        }
예제 #2
0
        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join <T>(char separator, ReadOnlySpan <T> values)
        {
            var sb = new Utf8ValueStringBuilder(true);

            try
            {
                for (int i = 0; i < values.Length; i++)
                {
                    if (i != 0)
                    {
                        sb.Append(separator);
                    }
                    sb.Append(values[i]);
                }
                return(sb.ToString());
            }
            finally
            {
                sb.Dispose();
            }
        }
예제 #3
0
        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join <T>(string separator, List <T> values)
        {
            var sb = new Utf8ValueStringBuilder(true);

            try
            {
                var count = values.Count;
                for (int i = 0; i < count; i++)
                {
                    if (i != 0)
                    {
                        sb.Append(separator);
                    }
                    sb.Append(values[i]);
                }
                return(sb.ToString());
            }
            finally
            {
                sb.Dispose();
            }
        }