C#中int.TryParse超出int的值应该怎么办?
privatevoidbutton1_Click(objectsender,EventArgse){stringstr1=textBox1.Text;inti1;if(s...
private void button1_Click(object sender, EventArgs e)
{
string str1 = textBox1.Text;
int i1;
if (str1.Length != 18)
{
MessageBox.Show("您输入的身份证号不是18位数");
return;
}
if (int.TryParse(str1, out i1))
{
MessageBox.Show("您输入的值为非法值");
return;
}
string str2 = str1.Substring(6,4);
i1 = Convert.ToInt32(str2);
if (DateTime.Now.Year - i1 > 18)
{
pictureBox1.Visible = true;
}
else
{
pictureBox1.Visible = false;
}
}
} 展开
{
string str1 = textBox1.Text;
int i1;
if (str1.Length != 18)
{
MessageBox.Show("您输入的身份证号不是18位数");
return;
}
if (int.TryParse(str1, out i1))
{
MessageBox.Show("您输入的值为非法值");
return;
}
string str2 = str1.Substring(6,4);
i1 = Convert.ToInt32(str2);
if (DateTime.Now.Year - i1 > 18)
{
pictureBox1.Visible = true;
}
else
{
pictureBox1.Visible = false;
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询