Its a very interesting thing not sure why it happens but when I do:
(item.Count / query.Count) * 100
It will not give me any errors just reply with 0 and when I do:
(item.Count * 100) / query.Count
It works just fine, what am I missing here ?
Another problem I am having is formatting the output of it to string:
double perc = (item.Count * 100) / query.Count;
MessageBox.Show(perc.ToString("P5"));
Does not work gives me a huge sum like 33,333.33 or 33,000.00, I wanted it to look like this 33.33%, I tried several variations but for some reason it will not let me get the .33 if I set the parenthesis to double it gets me .00 and if I do not it doesn’t give me .33
Don’t multiply by 100, the Percent Format Specifier will do that for you. Just cast to
doublewhen you perform the division: