I’m trying to think of clever, clear, and simple ways to write code that describes the sequence of integers in a given range.
Here’s an example:
IEnumerable<int> EnumerateIntegerRange(int from, int to) { for (int i = from; i <= to; i++) { yield return i; } }
This is already in the framework: Enumerable.Range.
For other types, you might be interested in the range classes in my MiscUtil library.