Tc Kimlik Numarasının Gerçek Tc Kimlik Olup Olmadığını Kontrol Eder. Basit Doğrulama.
Algoritma Doğrulama TcDogrulaV2
public static bool TcDogrula(string tcKimlikNo)
{
bool returnvalue = false;
if (tcKimlikNo.Length == 11)
{
char[] charlar = tcKimlikNo.ToCharArray(0, 10);
int sayi = 0;
foreach (char item in charlar)
{
sayi += int.Parse(item.ToString());
}
string sayistr = sayi.ToString();
if (sayistr.Substring(sayistr.Length - 1) == tcKimlikNo.Substring(10))
{
returnvalue = true;
}
}
return returnvalue;
}
VB
Public Shared Function TcDogrulaV1(ByVal tcKimlikNo As String) As Boolean
Dim returnvalue As Boolean = False
If (tcKimlikNo.Length = 11) Then
Dim charlar As Char() = tcKimlikNo.ToCharArray(0, 10)
Dim sayi As Integer = 0
Dim item As Char
For Each item In charlar
sayi = (sayi + Integer.Parse(item.ToString))
Next
Dim sayistr As String = sayi.ToString
If (sayistr.Substring((sayistr.Length - 1)) = tcKimlikNo.Substring(10)) Then
returnvalue = True
End If
End If
Return returnvalue
End Function