Ejemplo n.º 1
0
        public static Integer Parse(string value, bool positive = true, bool hex = false)
        {
            if (!hex && !Regex.IsMatch(value, @"^-?[0-9]+$") ||
                hex && !Regex.IsMatch(value, @"^-?[0-9a-fA-F]+$"))
            {
                throw new ArgumentException($"String was not in correct format: {value}.");
            }

            return(value.StartsWith("-") ? new Integer(Natural.Parse(value.Substring(1)), false) : new Integer(Natural.Parse(value), positive));
        }