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


C# Money.DisplayNative方法代码示例

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


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

示例1: Currency_creation_creates_meaningful_display_cultures

        public void Currency_creation_creates_meaningful_display_cultures()
        {
            // If I'm from France, and I reference Canadian Dollars,
            // then the default culture for CAD should be fr-CA
            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
            CurrencyInfo currencyInfo = Currency.CAD;
            Assert.AreEqual(currencyInfo.DisplayCulture, new CultureInfo("fr-CA"));

            // If I'm from England, and I reference Canadian Dollars,
            // then the default culture for CAD should be en-CA
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
            currencyInfo = Currency.CAD;
            Assert.AreEqual(currencyInfo.DisplayCulture, new CultureInfo("en-CA"));

            // If I'm from Germany, and I reference Canadian Dollars,
            // then the default culture for CAD should be Canadian
            Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
            currencyInfo = Currency.CAD;
            Assert.AreEqual(new CultureInfo("en-CA"), currencyInfo.DisplayCulture);

            // ... and it should not display as if it were in de currency!
            Money money = new Money(Currency.CAD, 1000);
            Assert.AreEqual("$1,000.00", money.DisplayNative());

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-CA");
            money = new Money(1000);
            var german = new CultureInfo("de-DE");
            Console.WriteLine(money.DisplayIn(german));  // Output: $1,000.00
        }
开发者ID:QMTech,项目名称:money,代码行数:29,代码来源:CurrencyTests.cs


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