|
|
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. |
|
Note: Only registered ShinyDonkey.com users
can post images. Only administrators can delete images.
New messages disabled indefinitely due to SPAM.