1
Vote

Create a ValidRange class, extending Range

description

Right now if I do this:

var range = new Range<int>(5, 2);

That works, the object just sets Start to 2, and End to 5. There are cases where we want a validated range - that is, start should be less than or equal to end, and throw an exception otherwise.

Therefore:
  • Unseal Range<T>
  • Create ValidRange<T> that inherits from Range<T> and adds that validation in the constructor.

comments