Regional Settings -- CultureInfo ???

  • Thread starter Thread starter 2989coder
  • Start date Start date
2

2989coder

After a few mishaps my program that writes to a text
file is finished.

After installing it on a test machine if failed to work
because the "standard" computers have portuguese set in
Regional Settings -- and they don't understand

value = 13.50

and they write that as

value = 13,50


I know I can write a function to read and write the values
on a char-by-char basis, but there certainly is something
easier and already made, isn't there?

What I have is (C#)

/* outfile is a StreamWriter */
outfile.WriteLine("value = {0:0.00}", 13.5);

which, running on a computer with '#' for the decimal point
will output

value = 13#50

I want it to *always* output

value = 13.50



Can somebody, please, point me in the right direction?
 
Hi 2989coder,
What I have is (C#)

/* outfile is a StreamWriter */
outfile.WriteLine("value = {0:0.00}", 13.5);

which, running on a computer with '#' for the decimal point
will output

value = 13#50

I want it to *always* output

value = 13.50

You should *always* use "CultureInfo.InvariantCulture"!
double val = 13.5;
WriteLine("value={0}", val.ToString("0.00", CultureInfo.InvariantCulture);

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
Ah!

Many, many thanks Jochen.

I thought CultureInfo would be part of the solution,
but didn't find how to use it.

Best regards,
Pedro
 
Back
Top