Created
May 6, 2019 12:45
-
-
Save nesendal/96a3427ad40cb88db65887ca6f2fb025 to your computer and use it in GitHub Desktop.
TCNoKimlikNo
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ClassKullanimiOrnek | |
{ | |
class PersonBilgi | |
{ | |
public int Id { get; set; } | |
public string Ad { get; set; } | |
public string Soyad { get; set; } | |
//T.C. Kimlik No, 11 hanelidir. | |
//Her hane rakamsal bir değere sahiptir. | |
//İlk hanenin değeri 0 (sıfır) olamaz. | |
//İlk 9 hane üzerinde kurulan bir algoritma 10. hanenin değerini verir. | |
//1,3,5,7 ve 9. hanelerin değerlerinin toplamının 7 katından, 2,4,6 ve 8. hanelerin değerlerinin toplamını çıkartıp, elde ettiğimiz sonucun Mod10'unu alırsak (yani 10'a bölümünden kalan değer), T.C.Kimlik No içerisindeki 10. hanenin değerini elde ederiz. | |
//İlk 10 hane üzerinde kurulan başka bir algoritma, 11. hanenin değerini verir. | |
//İlk 10 hanenin değerleri toplamının Mod10'u, T.C. Kimlik No içerisindeki 11. hanenin değerini verir. | |
private long tcno; | |
public long Tcno | |
{ | |
get { return tcno; } | |
set | |
{ | |
int bir, iki, uc, dort, bes, alti, yedi, sekiz, dokuz, on, onbir; | |
string deger = value.ToString(); | |
int adet = deger.Length; | |
if (adet == 11) | |
{ | |
string birinci = deger.Substring(0, 1); | |
string ikinci = deger.Substring(1, 1); | |
string ucuncu = deger.Substring(2, 1); | |
string dorduncu = deger.Substring(3, 1); | |
string besinci = deger.Substring(4, 1); | |
string altinci = deger.Substring(5, 1); | |
string yedinci = deger.Substring(6, 1); | |
string sekizinci = deger.Substring(7, 1); | |
string dokuzuncu = deger.Substring(8, 1); | |
string onuncu = deger.Substring(9, 1); | |
string onbirinci = deger.Substring(10, 1); | |
bir = Convert.ToInt32(birinci); | |
iki = Convert.ToInt32(ikinci); | |
uc = Convert.ToInt32(ucuncu); | |
dort = Convert.ToInt32(dorduncu); | |
bes = Convert.ToInt32(besinci); | |
alti = Convert.ToInt32(altinci); | |
yedi = Convert.ToInt32(yedinci); | |
sekiz = Convert.ToInt32(sekizinci); | |
dokuz = Convert.ToInt32(dokuzuncu); | |
on = Convert.ToInt32(onuncu); | |
onbir = Convert.ToInt32(onbirinci); | |
int son = ((((bir + uc + bes + yedi + dokuz) * 7) - (iki + dort + alti + sekiz)) % 10); | |
if (son == on) | |
{ | |
int ilkonhanetoplam = bir + iki + uc + dort + bes + alti + yedi + sekiz + dokuz + on; | |
int onnbir = ilkonhanetoplam % 10; | |
if (onbir == onnbir) | |
{ | |
tcno = Convert.ToInt64(value); | |
} | |
} | |
} | |
} | |
} | |
public PersonBilgi() | |
{ | |
} | |
public PersonBilgi(int _id, string _ad) | |
{ | |
Id = _id; | |
Ad = _ad; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment