Hi,
Convert and Int.Parse are similar, with one important exception, if you are
converting a String and this string is null it will give you an exception,
wheather Convert will give you 0
a cast is a completely different thing though. It will work only if the
instance is a boxed int, or a boxed/unboxed value type that can be
converted implicitely to int .
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn**************************@127.0.0.1...
=?Utf-8?B?Q29kZVJhem9y?= <Co*******@discussions.microsoft.com> wrote in
news:6A**********************************@microsof t.com: Is there any sort of convention as to when its appropriate to use
int.Parse(), Convert.ToInt32() or casting to int?
If from a string, its better to Parse (ie parse or Convert)
I know that int.Parse is for creating an int from a string, but for
Convert.ToInt32() would do the same thing.
Convert calls Parse, tehy are nearly identical.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/