当前位置: 首页>>代码示例>>C#>>正文


C# NumberFormatInfo.CurrencyNegativePattern属性代码示例

本文整理汇总了C#中System.Globalization.NumberFormatInfo.CurrencyNegativePattern属性的典型用法代码示例。如果您正苦于以下问题:C# NumberFormatInfo.CurrencyNegativePattern属性的具体用法?C# NumberFormatInfo.CurrencyNegativePattern怎么用?C# NumberFormatInfo.CurrencyNegativePattern使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Globalization.NumberFormatInfo的用法示例。


在下文中一共展示了NumberFormatInfo.CurrencyNegativePattern属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

//引入命名空间
using System;
using System.Collections.Generic;
using System.Globalization;

public class Example : IComparer<CultureInfo>
{
   public static void Main()
   {
      // Assign possible values and their associated patterns to a 
      // generic Dictionary object.
      Dictionary<int, String> patterns = new Dictionary<int, String>();
      string[] patternStrings= { "($n)", "-$n", "$-n", "$n-", "(n$)", 
                                 "-n$", "n-$", "n$-", "-n $", "-$ n",
                                 "n $-", "$ n-", "$ -n", "n- $", "($ n)",
                                 "(n $)" };    
      for (int ctr = patternStrings.GetLowerBound(0); 
           ctr <= patternStrings.GetUpperBound(0); ctr++) 
         patterns.Add(ctr, patternStrings[ctr]);

      // Retrieve all specific cultures.
      CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
      Array.Sort(cultures, new Example());
      
      double number = -16.335;
      // Display the culture, CurrencyNegativePattern value, associated pattern, and result.
      foreach (var culture in cultures) 
         Console.WriteLine("{0,-15} {1,2} ({2,5}) {3,15}", culture.Name + ":", 
                           culture.NumberFormat.CurrencyNegativePattern,
                           patterns[culture.NumberFormat.CurrencyNegativePattern],
                           number.ToString("C", culture));
   }
   
   public int Compare(CultureInfo x, CultureInfo y) 
   {
      return String.Compare(x.Name, y.Name);                           
   }
}
// A portion of the output appears as follows:
//       ca-ES:           8 ( -n $)        -16,34 €
//       co-FR:           8 ( -n $)        -16,34 €
//       cs-CZ:           8 ( -n $)       -16,34 Kč
//       cy-GB:           1 (  -$n)         -£16.34
//       da-DK:          12 ( $ -n)      kr. -16,34
//       de-AT:           9 ( -$ n)        -€ 16,34
//       de-CH:           2 (  $-n)       Fr.-16.34
//       de-DE:           8 ( -n $)        -16,34 €
//       de-LI:           2 (  $-n)       CHF-16.34
//       de-LU:           8 ( -n $)        -16,34 €
//       dsb-DE:          8 ( -n $)        -16,34 €
开发者ID:.NET开发者,项目名称:System.Globalization,代码行数:50,代码来源:NumberFormatInfo.CurrencyNegativePattern


注:本文中的System.Globalization.NumberFormatInfo.CurrencyNegativePattern属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。