0

Greetings.

Ok so my problem is that I get a "Currency" formatted value from the database and this value sometimes comes as a whole number (without decimals) and sometimes it doesn't.

But, when I output the information as "string" into an XML File, I always need to show the 2 decimal places even if they are zero.

I tried with the following code:

price = string.Format("{0:N2", decimalPrice);

This works if e.g: the variable decimalPrice has a value of 59.33
However if it has a value of 59 this will not work, and will throw a format exception.

Any suggestions?

Thanks,

CB

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by charlybones
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.