public decimal To(Currency toCurrency) { if (_fromCurrency == toCurrency) { return(_value); } if (ConversionRates.TryGetValue(Tuple.Create(_fromCurrency, toCurrency), out decimal rate)) { return(_value * rate); } if (ConversionRates.TryGetValue(Tuple.Create(toCurrency, _fromCurrency), out rate)) { return(_value / rate); } throw new ArgumentOutOfRangeException($"Can't convert from {_fromCurrency} to {toCurrency}."); }
public void setConversionRate(ConversionRates enumVal) { conversionRate = (int)enumVal; }