1

I have some doubles that I want to format as strings so that they look like this:

   $ 123.00
($ 3,231.99)
     $ 0.82

So basically I need to get the positive doubles to print with a single trailing space. Here is the string formatted:

Value1.ToString("$ #,0.00 ;($ #,0.00);$ 0.00 ");

However, when they are being printed, on the web page the trailing space is not included. What am I missing?

1
  • Perhaps use a non-breaking space ( ) or a CSS white-space style Commented Mar 5, 2016 at 19:46

2 Answers 2

2

You need to add the non-breaking space character in your string. To do that, use unicode

\u00A0

Example:

string a = "b\u00A0cd"

Will be printed as:

b cd
Sign up to request clarification or add additional context in comments.

Comments

1

Use   for the space. Trailing spaces are not displayed by HTML.

1 Comment

This sounds promising - would you know how to correctly insert a non-breaking space into my format string? It's not working...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.