Det er fordi at index operatoren returnere en char. Og en char konverteret til int giver dig den pågældende chars Unicode værdi.
F.eks. har charen '1' Unicode-værdien 49.
Så det prøver du at kompensere for ved at subtrahere 49. I stedet kan man:
int t1 = Convert.ToInt32(cpr.Substring(0,1));
int t2 = Convert.ToInt32(cpr.Substring(1, 1));
int t3 = Convert.ToInt32(cpr.Substring(2, 1));
int t4 = Convert.ToInt32(cpr.Substring(3, 1));
int t5 = Convert.ToInt32(cpr.Substring(4, 1));
int t6 = Convert.ToInt32(cpr.Substring(5, 1));
int t7 = Convert.ToInt32(cpr.Substring(6, 1));
int t8 = Convert.ToInt32(cpr.Substring(7, 1));
int t9 = Convert.ToInt32(cpr.Substring(8, 1));
int t10 = Convert.ToInt32(cpr.Substring(9, 1));
Indlæg senest redigeret d. 20.09.2007 21:12 af Bruger #4522