如何在.net中的值后显示货币符号?

时间:2013-08-03 05:58:28

标签: c# asp.net globalization persian

我在asp.net申请中使用波斯文化。

我将价格显示为

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

这导致12,000 ريال其中ريال是波斯货币符号,但我希望货币符号在价值之后(波斯语从左到右,因此,“之后”,我的意思是在数字的左侧。)

我在Style="text-align: right"上尝试PriceLabel,在包含标签的dir="rtl"标记上尝试<td>,但这也没有帮助。

3 个答案:

答案 0 :(得分:1)

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 ريال

答案 1 :(得分:0)

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

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

我会自由地承认这是一种猜测,绝对不是完美的。

答案 2 :(得分: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;
    }
}
相关问题