Produce a round-trip string for a decimal type

Decimal is in fact a binary-decimal value (it uses base of 10, not 2 as in Double) and that's why there's no need to special exact representations like ToString("R");

  Decimal value = 123.456m;
  String result = value.ToString(CultureInfo.InvariantCulture); // <- That's enough 

See also for details:

http://csharpindepth.com/articles/general/decimal.aspx


The default output format for decimal round-trips, so you don't have to do anything special. It is just like int in that sense.


If you try,

decimal d1 = 1m / 3;
string s = d1.ToString();
decimal d2 = decimal.Parse(s);
// where d1 == d2 = true

You will see you do not need any extra formatting options to obtain a proper string representation.