Rounding double to integer
Hi,
I am new to C# 2005. I am reading Visual C# 2005 Express Edition and in Chapter 5, the author mentioned that for Rounding (double) correctly, you should use the Convert class. I tried and it DOES NOT work.
double dblValue = 2.5;
int intValueTotal1;
intValueTotal1 = Convert.ToInt32(dblValue);
It works for 2.6-2.9 but does not work for 2.5.
For Rounding 2.5, it should be 3 and NOT 2.
Any help? What should one use for Rounding? Thanks.
Regards,
NewBee
|