Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# 500pts: Formatting a number to us . as decimal holder

Posted on 2006-11-02
Medium Priority
219 Views
Hi there,

Can anyone help.. The machine i work on is in a european culture which mean decimal points are comas and comas are decimal points

i.e 20,000.45

here is 20.000,45

Hence I have a figure that arrives in a string in the form of 20.000,45 and i convert it to a double which i store in tempDouble ... at this stage it is good.. tempDouble = 20,000.45 so now i need a string representation of it .. so i do ToString ... but his converts it back to

20.000,45

System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
nfi.NumberDecimalSeparator = ",";
nfi.NumberGroupSeparator = "";
nfi.NumberDecimalDigits = 2;

tempDouble = double.Parse(valor,nfi);
valor = tempDouble.ToString();

What am i doing wrong?? Obviously the ToString is using the culture setup of the machine

ANy ideas?

Ian
0
Question by:ianinspain
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 48

Accepted Solution

AlexFM earned 2000 total points
ID: 17858252
You need to use Double.ToString Method (IFormatProvider) overload (here and in any other place, read FxCop guidelines). ToString function without parameters depends on the current culture. To get standard number representation, use ToString(CultureInfo.InvariantCulture).
0

Author Comment

ID: 17858449
excellent! thanks.. works a treat!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
###### Suggested Courses
Course of the Month11 days, 9 hours left to enroll