Joins the enumerators. - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Joins the enumerators.

Demo Code

//   Copyright (c) Daniel Dabrowski - rod.42n.pl. All rights reserved.
using global::System.Collections.Generic;
using global::System.Collections;
using global::System;

public class Main{
        /// <summary>
        /// Joins the enumerators.
        /// </summary>
        /// <typeparam name="T">The type of objects in enumerator.</typeparam>
        /// <param name="enums">The enums to join.</param>
        /// <returns>Joined enumerators.</returns>
        public static IEnumerable<T> JoinEnumerators<T>(params IEnumerable<T>[] enums)
        {/*from w ww. j ava2s  .com*/
            foreach (var e in enums)
            {
                foreach (var item in e)
                {
                    yield return item;
                }
            }
        }
        /// <summary>
        /// Joins the enumerators.
        /// </summary>
        /// <param name="enums">The enums to join.</param>
        /// <returns>Joined enumerators.</returns>
        public static IEnumerable JoinEnumerators(params IEnumerable[] enums)
        {
            foreach (var e in enums)
            {
                foreach (var item in e)
                {
                    yield return item;
                }
            }
        }
}

Related Tutorials