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

  • Thread starter Thread starter Daniel Walzenbach
  • Start date Start date
D

Daniel Walzenbach

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.
 
Daniel Walzenbach said:
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.
 
Thank you Armin,

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

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

Daniel Walzenbach said:
Thank you Armin,

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

Daniel
 
Back
Top