c# - Get Percentage of Width -
i have been looking through answers on here , know similar other questions have tried gives me incorrect result. drawing graph in c#. have width seen below.
public const int image_height = 1920; //canvas heigh public const int image_width = 1080; //canvas width public const int borehole_rect_width = (image_width / 2 - (10 * margin));
the important value borehole_rect_width returns 240. trying work out 15 percent of value. have checked on website below , others , 15 percent of 240 36.
however when use code below result of 6 not seem correct me.
int percent = (int)math.round((double)(100 * 15) / (double)borehole_rect_width);
i not sure im doing wrong appreciated.
te 15 percent of somethin need multiply 0.15. instance
var percent = value * 0.15; // if value == 240 thant percent 36
or can write method able percentage want example:
public double percentof(double percent, double number) { return number * (percent / 100); }
Comments
Post a Comment