By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,683 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,683 IT Pros & Developers. It's quick & easy.

??? difference between Double.Parse and Convert.ToDouble ???

P: n/a
Hi,
I wonder if somebody could explain me the difference between Double.Parse and Convert.ToDouble. If I'm not mistaken they are implemented differently (I though for a moment they might be the same like cint(anInt) and cType(anInt, System.Int32) but I checked with ildasm) - if I didn't made a mistake.
So when to use which syntax? Is there any performance penalty when using the one over the other or does anybody knows any differences?

' Example code **********************************
Dim myDouble As System.Double
Dim myString As System.String = "10"

myDouble = System.Double.Parse(myString)
myDouble = Convert.ToDouble(myString)

Thank you in advance!

--
Best regards

Daniel Walzenbach

P.S. If you need to contact me simply remove ".NOSPAM" from my email address.

Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Daniel Walzenbach" <da**********************@freudenberg.de>
schrieb
Hi,
I wonder if somebody could explain me the difference between
Double.Parse and Convert.ToDouble. If I'm not mistaken they are
implemented differently (I though for a moment they might be the same
like cint(anInt) and cType(anInt, System.Int32) but I checked with
ildasm) - if I didn't made a mistake. So when to use which syntax? Is
there any performance penalty when using the one over the other or
does anybody knows any differences?

' Example code **********************************
Dim myDouble As System.Double
Dim myString As System.String = "10"

myDouble = System.Double.Parse(myString)
myDouble = Convert.ToDouble(myString)


Convert.ToDouble calls System.Double.Parse. The only difference is that
Convert.ToDouble returns 0 when Nothing is passed, whereas Double.Parse
throws an exception.
--
Armin

Nov 20 '05 #2

P: n/a
Thank you Armin,

can you tell me how I can figure stuff like this out by myself?

Daniel

"Armin Zingler" <az*******@freenet.de> schrieb im Newsbeitrag
news:uQ**************@tk2msftngp13.phx.gbl...
"Daniel Walzenbach" <da**********************@freudenberg.de>
schrieb
Hi,
I wonder if somebody could explain me the difference between
Double.Parse and Convert.ToDouble. If I'm not mistaken they are
implemented differently (I though for a moment they might be the same
like cint(anInt) and cType(anInt, System.Int32) but I checked with
ildasm) - if I didn't made a mistake. So when to use which syntax? Is
there any performance penalty when using the one over the other or
does anybody knows any differences?

' Example code **********************************
Dim myDouble As System.Double
Dim myString As System.String = "10"

myDouble = System.Double.Parse(myString)
myDouble = Convert.ToDouble(myString)


Convert.ToDouble calls System.Double.Parse. The only difference is that
Convert.ToDouble returns 0 when Nothing is passed, whereas Double.Parse
throws an exception.
--
Armin

Nov 20 '05 #3

P: n/a
sorry to bother... I figured it out. All glory to the Hypno Toad :-) (i mean
ildasm)

"Daniel Walzenbach" <da**********************@freudenberg.de> schrieb im
Newsbeitrag news:#D*************@TK2MSFTNGP09.phx.gbl...
Thank you Armin,

can you tell me how I can figure stuff like this out by myself?

Daniel

"Armin Zingler" <az*******@freenet.de> schrieb im Newsbeitrag
news:uQ**************@tk2msftngp13.phx.gbl...
"Daniel Walzenbach" <da**********************@freudenberg.de>
schrieb
Hi,
I wonder if somebody could explain me the difference between
Double.Parse and Convert.ToDouble. If I'm not mistaken they are
implemented differently (I though for a moment they might be the same
like cint(anInt) and cType(anInt, System.Int32) but I checked with
ildasm) - if I didn't made a mistake. So when to use which syntax? Is
there any performance penalty when using the one over the other or
does anybody knows any differences?

' Example code **********************************
Dim myDouble As System.Double
Dim myString As System.String = "10"

myDouble = System.Double.Parse(myString)
myDouble = Convert.ToDouble(myString)


Convert.ToDouble calls System.Double.Parse. The only difference is that
Convert.ToDouble returns 0 when Nothing is passed, whereas Double.Parse
throws an exception.
--
Armin


Nov 20 '05 #4

P: n/a
"Daniel Walzenbach" <da**********************@freudenberg.de>
schrieb
sorry to bother... I figured it out. All glory to the Hypno Toad :-)
(i mean ildasm)


Yep, ildasm. :)
--
Armin

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.