You can use the Math.Round()
method to round a decimal number to the nearest tenth.
Here's an example:
main.cs93 chars3 lines
The Math.Round()
method takes two parameters: the first is the number you want to round, and the second is the number of decimal places to round to. In this example, we're rounding num
to 1 decimal place, which means it will be rounded to 10.3
.
gistlibby LogSnag