Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

EnableSoftware/Enable.Extensions.Interval

Repository files navigation

Enable.Extensions.Interval

Enable.Extensions.Interval provides a simple implementation of intervals in C#.

Examples

An Interval<T> is created by specifying the inclusive lower and upper bounds for the interval. For example, for integer values, we can create an interval that represents the numbers zero to ten:

var interval = new Interval<int>(0, 10);

We can now test whether other integers fall within this range:

interval.Contains(-1); // returns `false`.
interval.Contains(0); // returns `true`.
interval.Contains(1); // returns `true`.
…
interval.Contains(10); // returns `true`.
interval.Contains(11); // returns `false`.

Intervals can be used with any type that implements IComparable, for example, integer types like byte, char and long, floating point types like float, double and decimal and date/time types like TimeSpan and DateTimeOffset.

Releases

No releases published

Packages

No packages published

Languages