Created
July 9, 2016 23:53
-
-
Save DannyFeliz/309daa0b1d62001c2bcb909a182fb91d to your computer and use it in GitHub Desktop.
valida cedula
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool validaCedula(string pCedula) | |
{ | |
int vnTotal = 0; | |
string vcCedula = pCedula.Replace("-", ""); | |
int pLongCed = vcCedula.Trim().Length; | |
int[] digitoMult = new int[11] { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1 }; | |
if (pLongCed < 11 || pLongCed > 11) | |
return false; | |
for (int vDig = 1; vDig <= pLongCed; vDig++) | |
{ | |
int vCalculo = Int32.Parse(vcCedula.Substring(vDig - 1, 1)) * digitoMult[vDig - 1]; | |
if (vCalculo < 10) | |
vnTotal += vCalculo; | |
else | |
vnTotal += Int32.Parse(vCalculo.ToString().Substring(0, 1)) + Int32.Parse(vCalculo.ToString().Substring(1, 1)); | |
} | |
if (vnTotal % 10 == 0) | |
return true; | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment