private bool CheckCardNumber(string number) 
{ 
    int[] iW = new int[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 }; 
    int iSum = 0; 
    for (int i = 0; i < 17; i++) 
    { 
        int iVal = 0; 
        int.TryParse(number[i].ToString(), out iVal); 
 
        iSum += iVal * iW[i]; 
    } 
 
    int iCheck = iSum % 11; 
 
    string check = string.Empty; 
 
    switch (iCheck) 
    { 
        case 0: check = "1"; break; 
        case 1: check = "0"; break; 
        case 2: check = "x"; break; 
        case 3: check = "9"; break; 
        case 4: check = "8"; break; 
        case 5: check = "7"; break; 
        case 6: check = "6"; break; 
        case 7: check = "5"; break; 
        case 8: check = "4"; break; 
        case 9: check = "3"; break; 
        case 10: check = "2"; break; 
    } 
 
    string valid = number[17].ToString().ToLower(); 
 
    return valid == check; 
} 

相关文章:

  • 2021-08-03
  • 2022-03-03
  • 2021-09-27
  • 2021-09-23
  • 2021-12-29
  • 2022-02-12
  • 2022-12-23
猜你喜欢
  • 2021-09-11
  • 2022-12-23
  • 2021-12-23
  • 2021-12-23
  • 2021-12-23
  • 2021-09-11
  • 2021-09-11
相关资源
相似解决方案