Now is the time to destroy for
statement and use foreach
.
using System;
using ValueEnumerable;
var array = new[] { 1, 1, 2, 3, 5 };
foreach ((int num, int index) in array.Indexed()) {
Console.WriteLine($"{index}: {num}");
}
0: 1
1: 1
2: 2
3: 3
4: 5
using System;
using ValueEnumerable;
foreach (int i in new RangeExclusive(0, 10)) {
Console.WriteLine(i);
}
0
1
2
3
4
5
6
7
8
9
using System;
using ValueEnumerable;
foreach (int i in new RangeInclusive(0, 10)) {
Console.WriteLine(i);
}
0
1
2
3
4
5
6
7
8
9
10