can any one explain me diff. b/w (int32)ft, Convert.ToInt32(ft);
float ft=123.45f;
int nm = (Int32)ft;
int nm2=Convert.ToInt32(ft);
int nm = (Int32)ft;
int nm2=Convert.ToInt32(ft);
Both give same output
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Mar 5, 2015, 3:09 PM
A cast always rounds towards zero.
However, Convert.ToInt32 rounds to the nearer integer. If the float is halfway between two integers, the even integer is returned. So 123.5f would round to 124 rather than 123.
Pankaj Kumar ChoudharyPosted Mar 5, 2015, 9:01 PM