what is diffrence between convert.toint32 and int.parse

hi all.

when should i use: Convert.ToInt32("") and when to use int.parse("") ?

[114 byte] By [shimshon] at [2007-12-29]
# 1
If you use Lutz Roeder's Reflector to inspect the implementation of Convert.ToInt32(string), you'll find that it calls int.Parse(string, CurrentCulture).

So it doesen't really matter which one you call.

MatthewWatson at 2007-9-5 > top of Msdn Tech,Visual C#,Visual C# General...
# 2

Hi, shimshon

When either is applied to casting string into int, those two methods are the same as Matthew said.

The real difference is that convert.ToInt32(object obj) we see it can applied to other types besides string, while Int.Parse() is applied to string only.

Thank you

FigoFei-MSFT at 2007-9-5 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
Use Convert class when you convert object type that contains type in which you want to convert. For example when you execute ExecuteScalar of SqlDataReader it will return object type result but you know which type of object you expect and you use Convert.ToInt32, Convert.ToString or some other, to get the value. Same is when you want to get SelectedItem of the combo which is of type object but contains string and you need to use Convert.ToString to get the selected value.
'type'.Parse or 'type'.TryParse can be used only when converting string which contain targeted value type.
boban.s at 2007-9-5 > top of Msdn Tech,Visual C#,Visual C# General...