我有以下代码:转换与输出参数类型
DateTime? toDate = null;
DateTime.TryParseExact(toDateTextBox.Text, "dd-MM-yyyy", null,
System.Globalization.DateTimeStyles.None, out toDate);
Error: cannot convert from 'out System.DateTime?' to 'out System.DateTime'
我不知道为什么它是不可能的转换通过DateTime?
到DateTime
,尽管它实际上是从DateTime
的转换DateTime?
。
的可能重复[C#:为什么不“裁判”和“出”支持多态性] (http://stackoverflow.com/questions/1207144/c-why-doesnt-ref-and-out-support-polymorphism) – digEmAll 2011-04-04 09:27:42