As part of a task for my first programming assignment we were required to create a program which tells the user how old they are in days, I've completed that however we need to use a try/catch. We've never been taught anything about them just basic concepts like classes/variables/arrays. Here is my code I need to add something in to simply tell the user if the DateTime object DateOfBirth is invalid in a text box and to start again, currently an invalid DOB just crashes the program. Here is is the code which calculates everything.
private void buttonDaysOld_Click(object sender, EventArgs e)
{
DateTime DateOfBirth = new DateTime((int)comboBoxYear.SelectedItem, comboBoxMonth.SelectedIndex + 1, (int)comboBoxDay.SelectedItem);
TimeSpan diff = DateTime.Now - DateOfBirth;
int AgeInDays = (int)diff.TotalDays;
MessageBox.Show(textBoxName.Text+" you are "+(AgeInDays.ToString())+ " Days Old");
}