You can do this:
float f = 123.4563434;
float truncatedToTwoDigits = Math.Truncate(f * 100) / 100;
After multiplying
f
by 100, you get
12345.63434
. If you truncate everything after the decimal point (that's what Math.Truncate does), you get
12345
. By dividing that by 100, you get
123.45
, which is the result you desired.
You can do this for any
n digits after the decimal point, then just multiply and divide by
10n instead of 100.