/// <summary> /// It expects input as (INR) i.e the currency to whic user wants to convert /// </summary> /// <param name="toCurrency"></param> /// <returns></returns> public Money Convert(string toCurrency) { if (string.IsNullOrWhiteSpace(toCurrency) || toCurrency.Length != 3 || Regex.IsMatch(toCurrency, @"^[a-zA-Z]+$") == false) { throw new System.Exception(Resource.InvalidCurrency); } var convert = new ConvertCurrency(); var exchangerate = convert.Convert(this.Currency, toCurrency); var totalAmount = exchangerate * this.Amount; if (double.IsPositiveInfinity(totalAmount) || totalAmount > double.MaxValue) { throw new System.Exception(Resource.OutOfRange); } return(new Money(totalAmount, toCurrency)); }