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

(float)Convert.ToDouble c#.net c# 2003/2005

Hi group,

I've found some code that I want to use in a project that I am working
on, but the code is for c# .net and not 2003 or 2005 that I have
available.
In this code the program yells on (float)Convert.ToDouble(xml.value)
(which in this case is "8.25").
I am wondering if someone could tell me how the command is changed in
2003 or 2005 as it stops here.

best

Trond

Sep 26 '07 #1
2 2317
On Sep 26, 9:07 am, trondhuso <tr-h...@online.nowrote:
Hi group,

I've found some code that I want to use in a project that I am working
on, but the code is for c# .net and not 2003 or 2005 that I have
available.
In this code the program yells on (float)Convert.ToDouble(xml.value)
(which in this case is "8.25").
I am wondering if someone could tell me how the command is changed in
2003 or 2005 as it stops here.

best

Trond
I actually found the solution right after this posting. the reason is
that I am in a country where we use comma as a decimal separator, so I
had to change it.
the changes are:
System.Globalization.CultureInfo enUSCulture = new
System.Globalization.CultureInfo("en-US");
(float)Convert.ToDouble(xml.Value, enUSCulture);

Sep 26 '07 #2

"trondhuso" <tr*****@online.nowrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
On Sep 26, 9:07 am, trondhuso <tr-h...@online.nowrote:
>Hi group,

I've found some code that I want to use in a project that I am working
on, but the code is for c# .net and not 2003 or 2005 that I have
available.
In this code the program yells on (float)Convert.ToDouble(xml.value)
(which in this case is "8.25").
I am wondering if someone could tell me how the command is changed in
2003 or 2005 as it stops here.

best

Trond

I actually found the solution right after this posting. the reason is
that I am in a country where we use comma as a decimal separator, so I
had to change it.
the changes are:
System.Globalization.CultureInfo enUSCulture = new
System.Globalization.CultureInfo("en-US");
(float)Convert.ToDouble(xml.Value, enUSCulture);
You probably wanted the InvariantCulture if your data has a common,
international format.

Also, you might want to look into float.Parse or float.TryParse instead of
the Convert class.
Sep 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Cally | last post by:
Hello, I would like to convert a field from ntext field found in one database table to float field found in another database table. The reason why I want to do this is a long one. I have...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
3
by: ool | last post by:
Hello, How I can convert value from string to double. When I do this in that way: String sParam="150.00"; double dbValue= Convert.ToDouble(szParam); I get System.FormatEcxeption
5
by: Gustaf Liljegren | last post by:
Values altered when I convert from string to float and back again: using System; class FloatTest { static void Main(string args) { string var1 = "800856.22"; Console.WriteLine(var1);
1
by: Meya-awe | last post by:
Hello there, I am using a 3rd party library and a function which requires a float value in one of its methods. My data is in a string format and i tried using Convert.ToDouble and...
4
by: Gav | last post by:
Hi all, I have a value in a database which is of float and in order to get my value from my textbox into my database I am doing something along the line of sqlparm1.value=...
5
by: vivekaseeja | last post by:
Hi , Trying to convert a string value to a float value after reading the value from an XML file , but not sure what function to use. The following only works for integers Int32.Parse...
6
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar...
9
by: Marco Nef | last post by:
Hi there I'm looking for a template class that converts the template argument to a string, so something like the following should work: Convert<float>::Get() == "float"; Convert<3>::Get() ==...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...

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.