How to solve this issue
DateTime now = DateTime.Today;
DateTime s = (DateTime)dobcalender.SelectedDate;
int years = now.Year - s.Year;
if (now.Month < s.Month || (now.Month == s.Month && now.Day < s.Day))
--years;
tb_age.Text = years.ToString();
if (_data.Age >= 60)
{
_data.Citizen = "Senior";
}
else
{
_data.Citizen = "Junior";
}
Now the problem is that i have declared _data.Age is as int32.
i have to calculate the age from date of birth and also check whether the person is senior citizen or junior
Both values are calculated from the age.
_data.Age is declared as a
DateTimevariable. Change this to anintto resolve this error.