I have a DatePicker(CPTestDP) in our WPF window, and the date picked is saved into SQL datebase as text. I would like to use calculate the Age(how many days) based on today's date by below code. But it turns error at CFTestDP.SelectedDate
.
The error message says:
A property or indexer may not be passed as an out or ref parameter.
Could anyone help please? Much appreciate.
DateTime thisDay = DateTime.Today;
DateTime startDay = DateTime.TryParse(CFTestDP.SelectedDate, out CFTestDP.SelectedDate);
TimeSpan dateAge = thisDay - startDay;
txtAge.Text = string.Format("{dd}", dateAge);