ConvertTo() public method

Tries to convert the unit to the given unit.
public ConvertTo ( String unit ) : Double>>.List
unit String The unit (combination) to convert to.
return Double>>.List
Example #1
0
        public static UnitValue Convert(UnitValue fromValue, String targetUnit)
        {
            var cu          = new CombinedUnit(fromValue.Unit);
            var conversions = cu.ConvertTo(targetUnit);
            var re          = fromValue.Re;

            foreach (var conversation in conversions)
            {
                re = conversation(re);
            }

            return(new UnitValue(cu.Factor * re, cu.Unit));
        }
Example #2
0
        public static UnitValue Convert(UnitValue fromValue, String targetUnit)
        {
            var cu = new CombinedUnit(fromValue.Unit);
            var conversions = cu.ConvertTo(targetUnit);
            var re = fromValue.Re;

            foreach (var conversation in conversions)
            {
                re = conversation(re);
            }

            return new UnitValue(cu.Factor * re, cu.Unit);
        }