473,396 Members | 1,785 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,396 software developers and data experts.

how to convert string to double?

Hi,

In C#, how to convert a string to a double?

Thanks in advance!
Cindy

Nov 15 '05 #1
3 69783
String s = "1000.25";
Double d = Convert.ToDouble(s);

HTH
Kalpesh

"cindy liu" <ci****@spam.com> wrote in message
news:24*****************************@phx.gbl...
Hi,

In C#, how to convert a string to a double?

Thanks in advance!
Cindy

Nov 15 '05 #2
you could use one of the two methods here...

Convert.ToDouble()
Double.Parse ()

-----Original Message-----
Hi,

In C#, how to convert a string to a double?

Thanks in advance!
Cindy

.

Nov 15 '05 #3
You shoud use

Double.Parse( doubleString ) if you are sure current thread Culture is the
same as doubleString number represented in (decimal point char is important)
or
Double.Parse( doubleString, specificCulture ) if you have to convert from a
specific culture (see System.Globalisation)
or
Convert.ToDouble( doubleString ) to perform neutral culture conversion (so
decimal point should be "." )

so if you writes doubleString as
double d = 1.21
string doubleString = d.ToString()
or use WriteLine etc to write doubles you should use same culture to parse
values that was used when doubles were written to string.
"cindy liu" <ci****@spam.com> wrote in message
news:24*****************************@phx.gbl...
Hi,

In C#, how to convert a string to a double?

Thanks in advance!
Cindy

Nov 15 '05 #4

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
3
by: Norvin Laudon | last post by:
Hi, Can somebody explain the following, from the MSDN documentation for the "System.Convert.ToInt32(double)" function <quote> Return Value value rounded to the nearest 32-bit signed...
17
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge...
1
by: joe | last post by:
how to convert string to money before to insert to sql serve(sql db)
6
by: Doug | last post by:
Hi I have a short piece of trial code that compares some input and then produces a message based on the value. However I get a build error that i dont know how to resolve ' Cannot implicitly...
15
by: shiniskumar | last post by:
How to convert string to double? Ive got a double variable dTot; its value is 5.037717235E7 when i did FreemarkerTools.formatDecimal(dTot) i got it as string "50377172.35". now i want to...
5
oll3i
by: oll3i | last post by:
public class Cennik { private static Cennik instance = null; Map<String,Double> cennik = new HashMap<String,Double> (); private Cennik() { // prywatny konstruktor } public...
12
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
9
by: engteng | last post by:
How do I convert string to numeric in VB.NET 2003 ? Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle then not convert. Regards, Tee
1
by: chaitukdr | last post by:
Hi, I tried to convert string value 1.10 to double like double val=convert.todouble("1.10"); only 1.1 is given as result instead of 1.10 plz suggest me with a proper answer
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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,...

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.