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