Both the int.Parse and Convert.ToInt32 will return the same result. But the null handling only difference between them.
For example,
string str = "15";
int Val1= Convert.ToInt32(str);
int Val2= int.Parse(str);
From the above code, both Val1 and Val2 return the value as 15. Suppose the string value str has null value, Convert.ToInt32 will return zero and int.Parse will throw ArgumentNullException error.
For example,
string str=null;
int Val1= Convert.ToInt32(str);
int Val2 = int.Parse(str); //This will throw ArgumentNullException Error
That's it...
S.VinothkumaR.
Subscribe to:
Post Comments (Atom)
5 comments:
Hi Vinoth,
how are you ?
Your blog is really usefull.
Nice & useful Dude....
Nice & useful Dude....
Its really useful Vinoth. Thank you.
Its really useful Vinoth. Thank you.
Post a Comment