新的DateTime()与默认设置(日期时间) [英] new DateTime() vs default(DateTime)
本文介绍了新的DateTime()与默认设置(日期时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有理由选择其中一个比其他
Is there a reason to choose one of these over the other?
DateTime myDate = new DateTime();
或
DateTime myDate = default(DateTime);
他们两人都是平等的 1/1/0001十二点00分00秒AM
。
推荐答案
没有,它们是相同的。
默认()
,对于任何类型的值(的DateTime
是值类型)将随时拨打参数的构造函数。
default()
, for any value type (DateTime
is a value type) will always call the parameterless constructor.
这篇关于新的DateTime()与默认设置(日期时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文