本文介绍了格式字符串与尾随的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些双打,我想作为字符串格式化,让他们看起来像这样:
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?
推荐答案
您需要在您的字符串添加的非换空格字符。要做到这一点,采用UNI code
You need to add the non-breaking space character in your string. To do that, use unicode
\u00A0
例如:
string a = "b\u00A0cd"
将打印为:
b cd
这篇关于格式字符串与尾随的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!