public string ConverterParaOctal(string valor)
        {
            try
            {
                if (!System.Text.RegularExpressions.Regex.IsMatch(valor, "^[0-1]+$"))
                {
                    throw new FormatException();
                }

                CalculosDecimal calcDecimal = new CalculosDecimal();

                string valorDecimal = ConverterParaDecimal(valor);
                string valorOctal   = calcDecimal.ConverterParaOctal(valorDecimal);

                return("" + valorOctal);
            }
            catch (FormatException e)
            {
                return("Valor Invalido");
            }
        }
Пример #2
0
        public string ConverterParaOctal(string valor)
        {
            try
            {
                if (!System.Text.RegularExpressions.Regex.IsMatch(valor, @"\A\b[0-9a-fA-F]+\b\Z"))
                {
                    throw new FormatException();
                }

                string decimais = ConverterParaDecimal(valor);

                CalculosDecimal calc = new CalculosDecimal();

                string octa = calc.ConverterParaOctal(decimais);

                return(octa);
            }
            catch (FormatException e)
            {
                return("Valor Invalido");
            }
        }