Shiny Donkey!
Shiny Donkey! Shiny Donkey! Shiny Donkey!
                  Fake Banner Ads!  Mini-Sites!  
    New Shiny Donkey Posts  more >>
JER
Rob Miller
Rob Miller
satishreddy
* BREAKING NEWS *  9 out of 10 dentists recommend www.shiny-donkey.com instead of shinydonkey.com

.NET
[reply]   

01/21/04 08:22 AM EST
posted by JER email web

Which is better, Convert.ToInt32(string s) or int.Parse(string s) ?

At the IL level, they work as follows:

Convert.ToInt32 (string)
--> calls Int32.Parse
int.Parse (string) (really Int32.Parse(string)
--> calls Number.ParseInt32

So if you have a string to convert to an integer, it seems calling int.Parse is probably better.

Now this difference in performance is so negligible that this is more academic than practical -- you're safe either way.

Btw, "Number" is a private class, so you can't call it from your code w/o using reflection. :(

Also, the other 18 or so overloads generally behave similarly, calling their respective parse methods.

 

Name

 registered? log in!

E-mail (optional)

Website (optional)

  

To ensure security, this site requires unregistered users to enter a verification code:
 
Your code is:  
Enter Code:   

Note: Only registered ShinyDonkey.com users can post images. Only administrators can delete images.

  

New messages disabled indefinitely due to SPAM.



"And remember, a shiny new donkey for whoever brings me the head of Colonel Montoya..."
e-mail webmaster