麻烦各位大佬帮我看看这里哪里出错了,运行完会报错
using System;
using System.Text.RegularExpressions;
namespace _1901203021_廖海鹏
{
class Program
{
static void Main(string[] args)
{
Console.Write("身份证号码:");
string id = Convert.ToString(Console.ReadLine());
string expression = @"^d{18}$";
if (Regex.IsMatch(id, expression) == false)
{
Console.Write(false);
}
int[] wi = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
char[] checkNum = { '1', '0', 'x', '9', '8', '7', '6', '5', '4', '3', '2' };
//while (System.Text.Encoding.Default.GetByteCount(id) != 18)
//{
// Console.WriteLine("身份证输入错误,请重新输入");
// id = Convert.ToString(Console.ReadLine());
//}
//char[] ID = id.ToCharArray();
int[] ID = new int[id.Length];
for (int i = 0; i < id.Length; i++)
{
int ii = Convert.ToInt32(id[i]);
ID[i] = ii;
}
int S = 0;
for (int x = 0; x < 17; x++)
{
int Ai = ID[x];//将ID声明为int
int Wi = wi[x];
S += Ai * Wi;
}
int Y = S % 11;
Y = Convert.ToInt32(checkNum[Y]);
if (ID[18] == Y)
{
Console.WriteLine("校验成功,此身份证号为真");
}
else
{
Console.WriteLine("校验失败,此身份证号为假");
}
}
}
}