المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : What is the differentation between Convert.ToInt32() and (int) Casting



C# Programming
07-05-2009, 03:51 PM
My question boundaries in primitive data types, not object.

What is the differentation between Convert.ToInt32() and (int) casting ?

For example;

double test = 5.2;
int var1 = (int)test;
int var2 = Convert.ToInt32(test);

I know if I test variable initialize to 5.5
var1 = 5
var2 = 6

Another difference here?

Thanks...