【问题标题】:format currency with currency symbol at the front用货币符号在前面格式化货币
【发布时间】:2010-11-14 07:18:25
【问题描述】:

嗨 如何在前面使用欧元符号格式化货币。使用文化 fr-Fr 格式化的货币会导致货币符号在末尾和逗号而不是“。”

【问题讨论】:

    标签: c# format currency culture


    【解决方案1】:

    CultureInfo 类允许您确定此类设置。许多格式方法(例如String.Format() 通过IFormatProvider 参数)将CultureInfo 作为参数。您可以根据自己的要求配置CultureInfo 实例,例如可以使用NumberFormat 属性设置的货币符号设置。

    如果您希望这些设置应用于整个用户界面,请设置Thread.CurrentThread.CurrentCulture 和/或Thread.CurrentThread.CurrentUICulture 属性。许多将CultureInfo 作为参数的方法都会采用此设置。

    【讨论】:

    • 小数; CultureInfo 文化 = new CultureInfo("en-GB"); Culture.NumberFormat = new NumberFormatInfo();文化.NumberFormat.CurrencySymbol = "€"; if (Decimal.TryParse(amt, out amount)) return String.Format(culture, "{0:C}", amount);否则返回“-”;
    【解决方案2】:

    看看 NumberFormatInfo.CurrencyPositivePattern。 这里http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencypositivepattern(v=vs.110).aspx 是一个包含可能值的表。 NumberFormatInfo.CurrencyNegativePattern 也是如此。

    【讨论】:

      猜你喜欢
      • 2012-01-29
      • 1970-01-01
      • 1970-01-01
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 2018-03-29
      • 1970-01-01
      相关资源
      最近更新 更多