Exemplo n.º 1
0
        public string ToString(DistanceUnits unit, bool longVersion)
        {
            double num   = this.In(unit);
            string units = longVersion ? DistanceUnitInfo.GetPreferedLongUnitString(unit) : DistanceUnitInfo.GetPreferedShortUnitString(unit);

            return(string.Format("{0} {1}", num, units));
        }
Exemplo n.º 2
0
        private static Distance fromNumberAndString(double value, string unitText)
        {
            DistanceUnits?unit = DistanceUnitInfo.ParseUnit(unitText);

            if (unit != null)
            {
                return(Distance.FromDistance(value, unit.Value));
            }
            throw new InvalidOperationException("unknown unit: " + unit);
        }