Look at my code. Why does the Enumerable.Range() behave differently whether the start value is 0.
class Program
{
static void Main(string[] args)
{
var range1 = Enumerable.Range(0, 7);
PrintRange(range1);
var range2 = Enumerable.Range(1, 8);
PrintRange(range2);
Console.ReadKey(true);
}
private static void PrintRange(IEnumerable<int> myRange)
{
foreach (int i in myRange)
{
Console.WriteLine("Linha {0}\n", i);
}
Console.WriteLine("\n========================================\n");
}
}
The range itself is the same. however when it starts at 1, I get a larger one. 🙁
Here is the result:
Linha 0
Linha 1
Linha 2
Linha 3
Linha 4
Linha 5
Linha 6
========================================
Linha 1
Linha 2
Linha 3
Linha 4
Linha 5
Linha 6
Linha 7
Linha 8
========================================
The second argument is
countnotend.Your first call is equivalent to I want 7 consecutive integers starting with 0 while the second is I want 8 consectutive integers starting with 1.
MSDN Enumerable.Range