C# - Percentage

By , 12/22/2011
(1 ratings)
Returns a percent value of a number out of a given maximum.
public double Percent(double value, double max)
{
     return ((value * 100) / max);
}

public int Percent(int value, int max)
{
     return ((value * 100) / max);
}

// Either works, but the double method is more precise.
Tagged with percent, percentage.

Comments

 

Log in, to comment!

Related Snippets