Ejemplo n.º 1
0
        public static bool CheckFirstValid(string cpf)
        {
            double cpfValidationCalc;

            cpfValidationCalc = ((Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.First)) * ValueToCalc.Ten)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Second)) * ValueToCalc.Nine)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Third)) * ValueToCalc.Eight)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Fourth)) * ValueToCalc.Seven)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Fifth)) * ValueToCalc.Six)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Sixth)) * ValueToCalc.Five)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Seventh)) * ValueToCalc.Four)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Eighth)) * ValueToCalc.Three)
                                 + (Convert.ToDouble(SplitCpfNumbers.SplitNumbers(cpf, CpfDigit.Ninth)) * ValueToCalc.Two));

            double cpfValidationResult;

            cpfValidationResult = (cpfValidationCalc * 10) % 11;

            if (cpfValidationResult.ToString(CultureInfo.InvariantCulture) == SplitCpfNumbers.SplitNumbers(cpf, 10))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static string RegionCpf(string cpf)
        {
            var region = new List <string>
            {
                "RS",
                "DF, GO, MS e TO",
                "PA, AM, AC, AM, RO e RR",
                "CE, MA e PI",
                "PE, RN, PB e AL",
                "BA e SE",
                "MG",
                "RJ e ES",
                "SP",
                "PR e SC"
            };

            return(region[Convert.ToInt32(SplitCpfNumbers.SplitNumbers(cpf, 9))]);
        }