16 August 2012

different between Parse and Convert

Convert class makes it easier to convert between the all the base types.
One Difference:
string is null
thrown error when you call int.Parse()
return 0 value when you call Convert.ToInt32()
if you want to know the Difference between Int.Parse() and Convert.ToINT32(). please test the following code:

int a, b;
string s = null;
b = Convert.ToInt32(s);
a = int.Parse(s);

Output is same when you use your code.

No comments: