private void button1_Click(object sender, EventArgs e)
{
DateTime dob = new DateTime();
textBox1.Text = dob.ToString();
int age;
age = Convert.ToInt32(textbox2.Text);
age = DateTime.Now.Year - dob.Year;
if (DateTime.Now.DayOfYear < dob.DayOfYear)
age = age - 1;
}
如何从 dob 计算年龄。这是我的 form1.cs。请有任何想法