1

我在我的asp.net应用程序中使用波斯文化。

我将价格显示为

PriceLabel.Text = string.Format("{0:C0}", 12000);

这导致波斯货币符号在12,000 ريال哪里ريال,但我希望货币符号出现在值之后(波斯从左到右,所以,“之后”,我的意思是数字的左侧)。

我已经尝试过Style="text-align: right",PriceLabel和包含标签dir="rtl"<td>标签,但这也没有帮助。

4

3 回答 3

3
var cultureInfo = new CultureInfo("fa-Ir");
cultureInfo.NumberFormat.CurrencyPositivePattern = 3;
cultureInfo.NumberFormat.CurrencyNegativePattern = 3;

var result = string.Format(cultureInfo, "{0:C0}", 12000);

Console.WriteLine(result);
//Result
//12,000 ريال
于 2013-08-03T06:13:02.170 回答
0

.NET 库正在做它们应该做的事情,并以您要求的格式显示货币。要改变这一点,你会破坏 i18n,但如果你知道波斯货币符号的 Unicode 值,你可以尝试使用 String.Format,例如

PriceLabel.Text = string.Format("{0} {1}", 12000, <insert unicode char here>);

我会坦率地承认这是一个猜测,而且绝对不完美。

于 2013-08-03T06:14:32.150 回答
0

当您在文本框中输入时,以下截图将转换为波斯货币格式:

private void textBox3_TextChanged(object sender, EventArgs e)
{
    decimal Number;
    if (decimal.TryParse(textBox3.Text, out Number))
    {
        textBox3.Text = string.Format("{0:N0}", Number);
        textBox3.SelectionStart = textBox3.Text.Length;
    }
}
于 2016-08-08T10:56:51.323 回答