I created an accreditation system where the user can take exams. When marking an exam, I want to return a percentage. So I take the right questions, dividing them by the number of questions on the exam and multiplying them by 100.
My problem is rounding the numbers up. So if the figure came back, it was 76.9, my code gives me 76, where it is rounded to 77, etc.
this is the line of code i that works with this ...
int userScorePercentageConvert = (int)decimal.Round((correctQuestionsForAttempt.Count / dvAttemptQuestions.Count * 100), MidpointRounding.AwayFromZero);
Can someone tell me how to change this piece of code so that it rounds correctly
i.e. 43,4 = 44 | 67.7 = 68 | 21.5 = 22
Thank you very much in advance.
source
share