using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DevelopStuff.Extensions
{
public static class DecimalMethods
{
///
/// Determines whether the decimal is within the specified range, inclusive.
///
/// The actual.
/// The lower.
/// The upper.
///
public static bool Within(this decimal actual, decimal lower, decimal upper)
{
return actual.Within(lower, upper, true);
}
///
/// Determines whether the decimal is within the specified range, inclusive..
///
/// The actual.
/// The lower.
/// The upper.
/// if set to true [inclusive].
///
public static bool Within(this decimal actual, decimal lower, decimal upper, bool inclusive)
{
if (lower > upper)
{
throw new ArgumentException("The lower bound can't be greater than the upper boundary.", "lower");
}
if (inclusive)
{
return ((actual >= lower) && (actual <= upper));
}
return ((actual > lower) && (actual < upper));
}
}
}