.NET 4.0 日历控件成员 SelectedDate 的类型为“DateTime?”?
在 .NET 4.0 中,如果创建日历并查看 SelectedDate 字段,它的类型为“DateTime?”。到底是怎么回事?在类型的末尾?
In .NET 4.0 if you create a Calendar and you look at the SelectedDate field it is of type "DateTime?". What's the deal with the ? at the end of the type?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
?最后意味着它可以为空,例如,控件可能根本没有 SelectedDate。
看:
http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx
? at the end means it's nullable, as in, the control may not have a SelectedDate at all.
See:
http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx
?最后意味着值类型也可以为 null。
? at the end means that a value type can also be null.
DateTime?
表示Nullable
,这意味着该属性可以保存null
。同时只是DateTime
- 不能。在 MSDN 上查看有关 可空类型的更多信息
DateTime?
meansNullable<DateTime>
that's meaning that this property can holdnull
. Meanwhile justDateTime
- cannot.See more about Nullable Types on MSDN