DataFormatString

  • Thread starter Thread starter Arjen
  • Start date Start date
A

Arjen

Hi,

I have to display a double like this one 1.3234546 and this 2.0000.
If the double is like the first one then I only want to display 1.32.

This works with {0:F2}.

But with the second one I like to display 2. Not 2.00.

How can I do this?

Thanks!
 
Well.... if you assing 2.0000000000 to a double, it will automatically
become 2, since there is no further precision required. you could solve
it with this:

Double dbl = 2.000000000000000000000;

if (dbl = Math.Floor(dbl))
{
return Convert.ToString(dbl) + ".00";
}
 
Back
Top