public static string Abbreviation(this DistanceEnum unitEnum) { switch (unitEnum) { case DistanceEnum.Inches: return("in."); case DistanceEnum.Feet: return("ft"); case DistanceEnum.Yards: return("yd"); case DistanceEnum.Miles: return("mi."); case DistanceEnum.Millimeters: return("mm"); case DistanceEnum.Centimeters: return("cm"); case DistanceEnum.Meters: return("m"); case DistanceEnum.Kilometers: return("km"); default: throw new ArgumentOutOfRangeException(nameof(unitEnum), unitEnum, null); } }
public static double ConversionFactor(this DistanceEnum unitEnum) { switch (unitEnum) { case DistanceEnum.Inches: return(1); case DistanceEnum.Feet: return(12); case DistanceEnum.Yards: return(36); case DistanceEnum.Miles: return(63360); case DistanceEnum.Millimeters: return(0.0393700787401575); case DistanceEnum.Centimeters: return(0.393700787401575); case DistanceEnum.Meters: return(39.3700787401575); case DistanceEnum.Kilometers: return(39370.0787401575); default: throw new ArgumentOutOfRangeException(nameof(unitEnum), unitEnum, null); } }
DistanceType(DistanceEnum unitEnum) { UnitEnum = unitEnum; }