I am working in progress bar concept in ASP.NET MVC 2. Here i have a DropDownList which has 10 values. i want to calculate the percentage for progress bar, e.g. 10 values from DropDownList and i am having a query which returns the value 2. so, out of 10 values i am getting 2. "20 % completed" should be displayed.. How to do this calculation
Using Math.Round()
:
int percentComplete = (int)Math.Round((double)(100 * complete) / total);
or manually rounding:
int percentComplete = (int)(0.5f + ((100f * complete) / total));