I would like to try to parse a string as a DateTime?, and if it fails then set the value to null. The only way I can think to do this is the following, but it doesn't seem very neat.
DateTime temp;
DateTime? whatIActuallyWant = null;
if (DateTime.TryParse(txtDate.Text, out temp)) whatIActuallyWant = temp;
Is this the only way?