-
-
-
-
-
- public static string GetModulus10Weight2(string Value)
- {
- bool result = Regex.IsMatch(Value, @"^[0-9]+$");
- if (!result)
- {
- return null;
- }
-
- int checkDigit = 0;
-
- for (int i = 0; i < Value.Length; i++)
- {
- checkDigit += int.Parse(Value.Substring(Value.Length - 1 - i, 1)) * (i % 2 == 0 ? 2 : 1);
- }
-
- checkDigit = 10 - (checkDigit % 10);
-
- checkDigit = checkDigit == 10 ? 0 : checkDigit;
-
- return checkDigit.ToString();
- }
///
/// モジュラス10/ウェイト2 計算
/// NW-7
///
/// ///
public static string GetModulus10Weight2(string Value)
{
bool result = Regex.IsMatch(Value, @"^[0-9]+$");
if (!result)
{
return null;
}
int checkDigit = 0;
for (int i = 0; i < Value.Length; i++)
{
checkDigit += int.Parse(Value.Substring(Value.Length - 1 - i, 1)) * (i % 2 == 0 ? 2 : 1);
}
checkDigit = 10 - (checkDigit % 10);
checkDigit = checkDigit == 10 ? 0 : checkDigit;
return checkDigit.ToString();
}
0 件のコメント:
コメントを投稿