Gert .Net
[GertDotNet]
20050323
Check a Belgium Rijksregisternummer (Part 3)
The code for this check is:
public static bool IsRijksregisternummer(string data) {
try {
if (data == null) return false;
if (data.Length != 11) return false;
string leftPartS = data.Substring(0,9);
string rightPartS = data.Substring(9);
int leftPartI = int.Parse(leftPartS);
int rightPartI = int.Parse(rightPartS);
// Special check for children of 21st century
int year = DateTime.Today.Year - 2000;
if (leftPartI < year * 10000000) {
leftPartI += 2000000000;
}
int mod = leftPartI % 97;
int compareTo = 97 - mod;
return compareTo == rightPartI;
} catch (ApplicationException) {
return false;
}
}
Comments:
Een reactie plaatsen
Links to this post:
