Пример #1
0
        public static DigitalStorageValue Parse(string value, string unit)
        {
            unit = unit.ToUpper();
            if (!Enum.TryParse(unit, out DigitalStorageUnit parsedUnit))
            {
                throw new ArgumentException("Unit " + unit + " could not be parsed.");
            }

            if (!int.TryParse(value, out int parsedValue))
            {
                throw new ArgumentException("Value " + value + " could not be parsed.");
            }

            return(new DigitalStorageValue(parsedValue, parsedUnit));
        }
Пример #2
0
 public DigitalStorageValue(int value, DigitalStorageUnit unit)
 {
     this.value = value;
     this.unit  = unit;
 }