William
William

Reputation: 3395

Format String with Trailing Space

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?

Upvotes: 1

Views: 273

Answers (2)

Ian
Ian

Reputation: 30813

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

Upvotes: 2

will
will

Reputation: 1511

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

Upvotes: 1

Related Questions