How do I use DateTime.TryParse with a Nullable<DateTime>?
问题 I want to use the DateTime.TryParse method to get the datetime value of a string into a Nullable. But when I try this: DateTime? d; bool success = DateTime.TryParse("some date text", out (DateTime)d); the compiler tells me 'out' argument is not classified as a variable Not sure what I need to do here. I've also tried: out (DateTime)d.Value and that doesn't work either. Any ideas? 回答1: DateTime? d=null; DateTime d2; bool success = DateTime.TryParse("some date text", out d2); if (success) d=d2;