change decimal point inf format double to string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have something like this:
string S = dblN.ToString("F4")

and S contain the decimal point as in the windows setting (currently ',' on
this machine). But I want it to be let's say: '.' always and independant the
setting on the machine.

Someone can explain the best (and fast) way to do this ?
 
Hi,

I have something like this:
string S = dblN.ToString("F4")

and S contain the decimal point as in the windows setting (currently ',' on
this machine). But I want it to be let's say: '.' always and independant the
setting on the machine.

Someone can explain the best (and fast) way to do this ?

Call the overloaded ToString method that takes an IFormatProvider, passing
a NumberFormatInfo object with the properties set according to your
preferences.
 
Wilfried,

Check the documentation for the ToString method. There is an overload
that allows you to pass your own format string to the method, which you can
use any kind of thousands separator you wish.

Hope this helps.
 
Back
Top