本文整理汇总了C#中Price.ConvertTo方法的典型用法代码示例。如果您正苦于以下问题:C# Price.ConvertTo方法的具体用法?C# Price.ConvertTo怎么用?C# Price.ConvertTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Price
的用法示例。
在下文中一共展示了Price.ConvertTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
var price1 = new Price(100, CurrencyCode.USD);
var price2 = new Price(55, CurrencyCode.EUR);
var price3 = Price.Parse(" 1000 rub ");
Console.WriteLine("price1 = {0}", price1);
Console.WriteLine("price2 = {0}", price2);
Console.WriteLine("price3 = {0}", price3);
Console.WriteLine();
Console.WriteLine("price1.ConvertTo BYR = {0}", price1.ConvertTo(CurrencyCode.BYR));
Console.WriteLine("price2 + price3 = {0:s}", price2 + price3);
Console.WriteLine();
Console.WriteLine("price1 | to BYR = {0:sBYR} | to RUB = {0:RUB} | to EUR = {0:sEUR}", price1);
Console.WriteLine("price2 | to BYR = {0:sBYR} | to RUB = {0:RUB} | to EUR = {0:EUR}", price2);
Console.WriteLine("price3 | to BYR = {0:sBYR} | to RUB = {0:RUB} | to EUR = {0:EUR}", price3);
price1.Currency = Currency.GetCurrency(CurrencyCode.BYR);
Console.WriteLine("price1.Currency = BYR {0}", price1);
Console.ReadLine();
}
示例2: TestConvertTo
public void TestConvertTo()
{
var price1 = new Price(100, CurrencyCode.USD);
var convertedPrice = price1.ConvertTo(CurrencyCode.BYR);
Assert.AreEqual(new Price(1045000, CurrencyCode.BYR), convertedPrice);
}