Creates an enumerable that iterates the range from Inclusive to Exclusive - CSharp System.Collections

CSharp examples for System.Collections:IEnumerable

Description

Creates an enumerable that iterates the range from Inclusive to Exclusive

Demo Code

//  Copyright (c) Microsoft Corporation.  All rights reserved. 
using System.Threading.Tasks;
using System.Numerics;
using System.Collections.Generic;
using System;//from w w  w . j  av a  2 s. co  m

public class Main{
        /// <summary>Creates an enumerable that iterates the range [fromInclusive, toExclusive).</summary>
        /// <param name="fromInclusive">The lower bound, inclusive.</param>
        /// <param name="toExclusive">The upper bound, exclusive.</param>
        /// <returns>The enumerable of the range.</returns>
        private static IEnumerable<BigInteger> Range(BigInteger fromInclusive, BigInteger toExclusive)
        {
            for (var i = fromInclusive; i < toExclusive; i++) yield return i;
        }
}

Related Tutorials