19 lines
532 B
C#
Executable File
19 lines
532 B
C#
Executable File
using System;
|
|
|
|
namespace Opsoft.NetCore.O3App.Shared
|
|
{
|
|
public static class IComparableExtensions
|
|
{
|
|
public static bool OutOfRange<T>(this T input, T rangeFrom, T rangeTo)
|
|
where T : IComparable<T>
|
|
{
|
|
if (rangeFrom.CompareTo(rangeTo) > 0)
|
|
{
|
|
throw new ArgumentException($"{nameof(rangeFrom)} should be less or equal than {nameof(rangeTo)}");
|
|
}
|
|
|
|
return input.CompareTo(rangeFrom) < 0 || input.CompareTo(rangeTo) > 0;
|
|
}
|
|
}
|
|
}
|