-1

I have several decimal numbers that I need to show as strings (no need for decimal places). I use the following code:

mytextblock.text= mydecimalnumber.ToString("#");

However this code will show nothing if the number is 0. I need to display a "0" instead of an empty string. I can do this using if and else but I don't think this is the best solution to do with many decimal variables.

user3340627
  • 3,023
  • 6
  • 35
  • 80

1 Answers1

0

Some user "David.." posted this answer and it worked for me but then he deleted it later:

He mentioned that ToString("#") will only show digits that are not zeros.

In order to default to 0, I should use ToString("0")

user3340627
  • 3,023
  • 6
  • 35
  • 80