|
using System;
namespace ColorPicker.ExtensionMethods
{
public static class DoubleExtensionMethods
{
public static int AsPercent (this double number)
{
return Convert.ToInt32(number*100);
}
public static double PercentageOf(this double number , double value)
{
return (number/value)*100;
}
public static double RestrictToRange(this double number , double min, double max)
{
return Math.Min(Math.Max(number, min), max);
}
public static byte RestrictToByte(this double number)
{
return Convert.ToByte(number.RestrictToRange(0,255));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Written software for what seems like forever. I'm currenly infatuated with WPF. Hopefully my affections are returned.