var query = from p1 in Enumerable.Range(2,3)
from p2 in Enumerable.Range(4,5)
select new { p1 , p2};
The result seems to be wrong
{ p1 = 2, p2 = 4 }
{ p1 = 2, p2 = 5 }
{ p1 = 2, p2 = 6 }
{ p1 = 2, p2 = 7 }
{ p1 = 2, p2 = 8 }
{ p1 = 3, p2 = 4 }
{ p1 = 3, p2 = 5 }
{ p1 = 3, p2 = 6 }
{ p1 = 3, p2 = 7 }
{ p1 = 3, p2 = 8 }
{ p1 = 4, p2 = 4 }
{ p1 = 4, p2 = 5 }
{ p1 = 4, p2 = 6 }
{ p1 = 4, p2 = 7 }
{ p1 = 4, p2 = 8 }
Help needed
I’m going to guess that you expected the results to be { 2, 4 }, { 2, 5 }, { 3, 4 }, { 3, 5 }. If that’s the case, perhaps you missed that the second parameter to
Enumerable.Rangeisn’t an upper bound – it’s a length. In that case, you want: