日期:2014-05-17  浏览次数:20773 次

新手来了 问几个问题……
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 身份证验证
{
    public partial class 隐藏文件查看 : Form
    {
        public 隐藏文件查看()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str1 = textBox1.Text;
            char[] chars = str1.ToCharArray();
            for (int i = 0; i < str1.Length; i++)
            {
                //int i3;
                //if (!i3==Convert.ToInt32(chars[i]))
                //{
                //    MessageBox.Show("身份证不能含有字母");
                //    return;
                //}    一个个扫描我输入的全是数字,这段代码要怎么写的
                if (str1.Length != 18)//身份证为的位数要为18位
                {
                    MessageBox.Show("请输入正确的身份证!");
                    return;
                }
                string str2 = str1.Substring(6, 4);
                int i1;
                if (!int.TryParse(str2, out i1))//截取的四位不是数字
                {
                    MessageBox.Show("你的身份证不能正常识别");
                    return;
                }
                int i2 = DateTime.Now.Year;