473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

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
4 10941
"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: cindy liu | last post by:
Hi, In .Net, how to convert a string to a double? Thanks in advance! Cindy
6
by: Marty | last post by:
Hi, If I don't know that my (or any) windows 2k regional setting for the decimal symbol is the dot (".") and I want to do this: 1- Dim dblOutput As Double 2- Dim strInput As...
0
by: R. John Reed | last post by:
Hi All, I'm am looking to convert a currency string (e.g. "$1,234.56" to a double value). It appears this will work: double val = Convert.ToDouble(Double.Parse­("$123,456.78901",...
9
by: Coleen | last post by:
Hi All :-) I found the way to get my column sum (Thanks Cor I did it a little different, but the result is what I wanted) I used: dt_stat_report_3b.Columns.Add(New DataColumn("Sum",...
5
by: SMichal | last post by:
Hi, how can I parse string "? 20.000" to double ?
10
by: Polaris431 | last post by:
I get a casting error when I execute the following: DateTime d = DateTime.Now; Double f = Convert.ToDouble(d); Why? The Convert.ToDouble has many overloads, one of them being the ability to...
14
by: kanepart2 | last post by:
Hi guys, I am having a problem with the following code snippet:- double x = (myReader); double y = (myReader); Resulting in the follwing compilation error: Cannot implicitly convert type...
4
by: Yoavo | last post by:
Hi, I want to convert a string to double. I use the function: "System.Convert.ToDouble". The problem is that if the string contains the character "." the program aborts. What might be the...
1
by: Bjorn Brox | last post by:
Hi! In germany, norway and France(?) we are using ',' as decimal separator and it always messes up when you convert a double to and from a string where the interface expects double values stored...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.