I'm trying to finish a quick "demonstration of learning" program by morning for Mothers Day. I've created a textbox for my mom to enter my birthday and a label to display the number of years, months, days, and seconds I've been alive when she clicks a button.
The following is the part of my code where I am stuck:
private void button1_Click(object sender, EventArgs e)
{
DateTime sonsBirthday = DateTime.Parse(txtSonsBirthday.Text).Date;
DateTime now = DateTime.Now;
TimeSpan timeSpan = now - sonsBirthday;
timeSpan = Convert.TimeSpan(lblTimeAlive); // blue squiggly under TimeSpan here
As I commented in the code, I get a blue squiggly under TimeSpan
in the last line; but I don't understand why. What am I doing wrong?
I'm just a student: so I've got the concept but am not used to datetime formats and need a little help.