コード例 #1
0
        public static AnyQuantity <double> GetUnitizedQuantityOf <TQuantity>(double value) where TQuantity : BaseQuantity, new()
        {
            MetricUnit unit = UnitOf <TQuantity>();


            AnyQuantity <double> aq = unit.GetThisUnitQuantity <double>();


            aq.Value = value;


            return(aq);
        }
コード例 #2
0
        private static AnyQuantity <double> MakeQuantity(MetricUnit unit, MetricPrefix siPrefix, double value)
        {
            //assign its prefix
            unit.UnitPrefix = siPrefix;

            //create the corresponding quantity
            AnyQuantity <double> qty = unit.GetThisUnitQuantity <double>();

            //assign the unit to the created quantity
            qty.Unit = unit;

            //assign the value to the quantity
            qty.Value = value;

            return(qty);
        }