I need to display a decimal monetary value as a string, where the dollars and cents will be separate with the text between them.
123.45 => "123 Lt 45 ct"
I came up with the following solution:
(value*100).ToString("#0 Lt 00 ct");
However, this solution has two drawbacks:
- By showing this solution to another programmer, it seems unintuitive and requires an explanation.
- Cents are always displayed as two digits. (Not a real problem for me, as this is currently the way I need it to display.)
Is there an alternative elegant and simple solution?
Domas source
share