本文整理汇总了C#中Currency.All方法的典型用法代码示例。如果您正苦于以下问题:C# Currency.All方法的具体用法?C# Currency.All怎么用?C# Currency.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency.All方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertTo
public static decimal ConvertTo(decimal fromAmount, CurrencyType fromCurrencyType, CurrencyType toCurrencyType, Currency[] currencies)
{
if (fromCurrencyType == toCurrencyType)
return fromAmount;
if ((fromCurrencyType != CurrencyType.CZK && currencies.All(c => c.CurrencyType != fromCurrencyType)) ||
toCurrencyType != CurrencyType.CZK && currencies.All(c => c.CurrencyType != toCurrencyType))
{
throw new Exception(String.Format(ValidationResource.Currency_CannotProccessCurrencyChange_ErrorMessage, fromCurrencyType, toCurrencyType));
}
decimal amountTo = fromAmount;
Currency currency;
// Převod konta na CZK
if (fromCurrencyType != CurrencyType.CZK)
{
currency = currencies.Single(c => c.CurrencyType == fromCurrencyType);
amountTo = amountTo * currency.ExchangeRateToCZK;
}
// Převod konta na aktuální měnu
if (toCurrencyType != CurrencyType.CZK)
{
currency = currencies.Single(c => c.CurrencyType == toCurrencyType);
amountTo = amountTo / currency.ExchangeRateToCZK;
}
return amountTo;
}