Instead of rounding, think about string formatting of numeric values with desired rounding. This is not exactly the same thing. Pure explicit rounding can be dangerous, because one could, by some reason, try to use rounded value and end up with loss of precision. There are very few cases when such rounding is needed (in random number generators, for example). Normally, you only need rounded value when you show it on scree, or something like that. So, you can just use formatting. For the type
System.Double
, for example, you will need this:
http://msdn.microsoft.com/en-us/library/system.double.tostring%28v=vs.110%29.aspx[
^].
For format specifiers, please see:
http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx[
^],
http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx[
^].
If you don't want to learn it all, you can use the
formatting utility:
https://code.msdn.microsoft.com/NET-Framework-4-Formatting-9c4dae8d[
^].
—SA