This is not how
Math.Round
works. Usually, rounding is done at a specific decimal position. So if you specify 1 decimal for rounding purpose, then essentially the answer would be the nearest number with 1 decimal.
Then you have some options to specify mid-point rounding. This is generally more useful for financial applications to reduce cumulative error.
If you want to round to a specific multiple like 0.5, then you have to add some extra code. For example, you might multiply by 2, round to unit and then divide by 2.
Here is the code with one operation per line and value in comment.
var value = 10.45;
value *= 2.0;
value = Math.Round(value, 0);
value /= 2.0;
However, how do you expect 1.20 to be rounded to 1.50. With above code, it will round to 1.00. Replacing
Math.Round
by
Math.Ceiling
might be what you want (however, you cannot specify the number of decimals).
Alternatively, you might want to add 0.5 before calling
Math.Round
. In that case, mid-point rounding might be more important.
For information on how rounding works, it might be useful to read documentation as it is very clear in documentation:
MidpointRounding Enumeration (System)[
^]