Hejka
Moglibyście ocenić i sprawdzić czy kod nie ma rażących błedów?
public static bool IsValidBankAccountNumber(string input)
{
bool result = false;
input = input.Replace(" ", String.Empty);
if (input.Length == 26 || input.Length == 32)
{
string checkSum = input.Substring(0, 2);
string accountNumber = input.Substring(2);
const int countryCode = 2521;
string reversedDigits = accountNumber + countryCode + checkSum;
int controlNum = ModString(reversedDigits, 97);
result = (controlNum == 1) ? true : false;
}
return result;
}
static int ModString(string x, int y)
{
if (x.Length == 0)
return 0;
string x2 = x.Substring(0, x.Length - 1); // first digits
int x3 = int.Parse(x.Substring(x.Length - 1)); // last digit
return (ModString(x2, y) * 10 + x3) % y;
}
Dzięki wielkie za odp.
Pozdrawiam,
Łukasz