473,672 Members | 3,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

??? difference between Double.Parse and Convert.ToDoubl e ???

Hi,
I wonder if somebody could explain me the difference between Double.Parse and Convert.ToDoubl e. 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.P arse(myString)
myDouble = Convert.ToDoubl e(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 11067
"Daniel Walzenbach" <da************ **********@freu denberg.de>
schrieb
Hi,
I wonder if somebody could explain me the difference between
Double.Parse and Convert.ToDoubl e. 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.P arse(myString)
myDouble = Convert.ToDoubl e(myString)


Convert.ToDoubl e calls System.Double.P arse. The only difference is that
Convert.ToDoubl e 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*******@free net.de> schrieb im Newsbeitrag
news:uQ******** ******@tk2msftn gp13.phx.gbl...
"Daniel Walzenbach" <da************ **********@freu denberg.de>
schrieb
Hi,
I wonder if somebody could explain me the difference between
Double.Parse and Convert.ToDoubl e. 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.P arse(myString)
myDouble = Convert.ToDoubl e(myString)


Convert.ToDoubl e calls System.Double.P arse. The only difference is that
Convert.ToDoubl e 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************ **********@freu denberg.de> schrieb im
Newsbeitrag news:#D******** *****@TK2MSFTNG P09.phx.gbl...
Thank you Armin,

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

Daniel

"Armin Zingler" <az*******@free net.de> schrieb im Newsbeitrag
news:uQ******** ******@tk2msftn gp13.phx.gbl...
"Daniel Walzenbach" <da************ **********@freu denberg.de>
schrieb
Hi,
I wonder if somebody could explain me the difference between
Double.Parse and Convert.ToDoubl e. 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.P arse(myString)
myDouble = Convert.ToDoubl e(myString)


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


Nov 20 '05 #4
"Daniel Walzenbach" <da************ **********@freu denberg.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
47065
by: cindy liu | last post by:
Hi, In .Net, how to convert a string to a double? Thanks in advance! Cindy
6
2183
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 String 3- strInput = "123,8" 4- dblOutput = Convert.ToDouble(strInput)
0
8403
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", System.Globalization.NumberSty­les.Currency));
9
2084
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", GetType(Double), "sum(Column_10_ld_act_125_gtr_fy_fy_hh_avg)")) where dt_stat_report_3b is my datatable, Sum is my column name and sum(Column_10_ld_act_125_gtr_fy_fy_hh_avg) is the sum of the column I needed. This Does return me the correct value in the...
5
23465
by: SMichal | last post by:
Hi, how can I parse string "? 20.000" to double ?
10
12060
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 convert a datetime value to a double. Thanks Johann
14
31497
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 'object' to 'double'. An explicit conversion exists (are you missing a cast?)
4
2565
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 problem ? Yoav.
1
4054
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 as string is using '.' What parameter shall I use in double.ToString() to ensure that the outputstring always are using '.' as separator without thousand sep, and what parameter shall I use to convert double to Double.Parse() or...
0
8419
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8846
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8643
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4242
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2837
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2093
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1837
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.