/// <summary> /// Returns a matching amount converted to the given unit. /// </summary> public Amount ConvertedTo(Unit unit) { // Performance optimization: if (Object.ReferenceEquals(this.unit, unit)) { return(this); } // Perform conversion: return(UnitManager.ConvertTo(this, unit)); }
/// <summary> /// Returns a matching amount converted to the given unit and rounded /// up to the given number of decimals. /// </summary> public Amount ConvertedTo(Unit unit, int decimals) { return(new Amount(Decimal.Round(UnitManager.ConvertTo(this, unit).Value, decimals), unit)); }