示例#1
0
        //--------------------------------------------------
        /// <inheritdoc cref="Concat{T}(T,System.Collections.Generic.IEnumerable{T})" />
        public static T Concat <T>([NotNull] T empty, [NotNull] params T[] items) where T : IAppendable <T>
        {
            if (items is null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            return(Appendable.Concat(empty, items.AsEnumerable()));
        }
示例#2
0
        //--------------------------------------------------
        /// <summary>
        /// Repeats <paramref name="item" /> <paramref name="times" />
        /// times, and concatenates the result.
        /// </summary>
        public static T Repeat <T>(this T item, [NotNull] T empty, int times) where T : IAppendable <T>
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (empty == null)
            {
                throw new ArgumentNullException(nameof(empty));
            }
            if (times < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(times));
            }

            return(Appendable.Concat(empty, Enumerable.Repeat(item, times)));
        }