471,627 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Parse and Convert

What's the difference between int.Parse(...) and Convert.ToInt32(...)?
Thank you
Dec 22 '05 #1
2 1215
alberto <al*****@nospam.es> wrote:
What's the difference between int.Parse(...) and Convert.ToInt32(...)?


int.Parse throws an exception if you pass it null. Convert.ToInt32
doesn't.

It's worth checking Google Groups before asking questions, by the way -
if you search for
difference Convert ToInt32 int Parse group:*.csharp
on groups.google.com, you get plenty of answers.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 22 '05 #2
Pull out Reflector and you can see exactly what is going on.
Convert.ToInt32(string) actually directly calls int.Parse() after checking
for null.

--
William Stacey [MVP]

"alberto" <al*****@nospam.es> wrote in message
news:u2*************@TK2MSFTNGP11.phx.gbl...
What's the difference between int.Parse(...) and Convert.ToInt32(...)?
Thank you

Dec 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jon Davis | last post: by
5 posts views Thread by Adam Klobukowski | last post: by
reply views Thread by Dr. Paul Caesar - CoullByte (UK) Limited | last post: by
2 posts views Thread by John Salerno | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.