Decimal.ToString Method

  • Thread starter Thread starter David Dvali
  • Start date Start date
D

David Dvali

How can I convert decimal value exactly to such format "0.00" (exactly with
dot, with ignoring of regional settings)?
 
How can I convert decimal value exactly to such format "0.00" (exactly with
dot, with ignoring of regional settings)?

Decimal d1 = 1.25M;
string result =

d1.ToString("0.00",System.Globalization.CultureInfo.InvariantCulture);
 
David said:
How can I convert decimal value exactly to such format "0.00" (exactly
with dot, with ignoring of regional settings)?

The best way to export data to string formats in a culture independant way
is to use the so-called InvariantCulture. Like this:

decimal val = 33.7m;
string strval = val.ToString(CultureInfo.InvariantCulture);

Here (MSDN) is more information about this: http://shrinkster.com/8fw


Oliver Sturm
 
Back
Top