Full repo available at https://bitbucket.org/createdbyx/codefarts.utilities-extension-methods-only
/// <summary>
/// Clamps the specified value.
/// </summary>
/// <param name="value">The value to be clamped.</param>
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <returns>The clamped value.</returns>
public static BaseType Clamp(this BaseType value, BaseType min, BaseType max)
{
if (value < min)
{
return min;
}
if (value > max)
{
return max;
}
return value;
}