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