System.Management.Pash.Implementation.ExecutionVisitor.Range C# (CSharp) Method

Range() private method

private Range ( int start, int end ) : IEnumerable
start int
end int
return IEnumerable
        private IEnumerable<int> Range(int start, int end)
        {
            //// Description:
            ////
            //// A range-expression creates an unconstrained 1-dimensional array whose elements are the values of
            //// the int sequence specified by the range bounds. The values designated by the operands are converted
            //// to int, if necessary (§6.4).

            //// The operand designating the lower value after conversion is the lower
            //// bound, while the operand designating the higher value after conversion is the upper bound.
            if (start < end)
            {
                return Extensions.Enumerable._.Generate(start, i => i + 1, end).ToArray();
            }

            //// Both bounds may be the same, in which case, the resulting array has length 1.
            if (start == end) return new[] { start };

            //// If the left operand designates the lower bound, the sequence is in ascending order. If the left
            //// operand designates the upper bound, the sequence is in descending order.
            if (end < start)
            {
                return Extensions.Enumerable._.Generate(start, i => i - 1, end).ToArray();
            }

            //// [Note: Conceptually, this operator is a shortcut for the corresponding binary comma operator
            //// sequence. For example, the range 5..8 can also be generated using 5,6,7,8. However, if an ascending
            //// or descending sequence is needed without having an array, an implementation may avoid generating an
            //// actual array. For example, in foreach ($i in 1..5) { … }, no array need be created. end note]
            ////
            //// A range-expression can be used to specify an array slice (§9.9).

            throw new Exception("unreachable");
        }
ExecutionVisitor