vb.net 日期而不是日期时间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5625795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:26:14  来源:igfitidea点击:

Date instead of DateTime?

vb.net

提问by poke

From what I can tell Dateand DateTimehave the same functionality. Is there a reason why I would want to use one instead of the other?

据我所知DateDateTime具有相同的功能。有什么理由让我想使用一个而不是另一个吗?

回答by R. Martinho Fernandes

In VB.NET Dateis an alias to System.DateTime, so yes, they're the same thing. You can see all the aliases in this charton MSDN.

在 VB.NET 中Date是 的别名System.DateTime,所以是的,它们是一样的。您可以在 MSDN 上查看此图表中的所有别名。

回答by Daniel DiPaolo

C# has no Datetype, but DateTimes do have a Datepropertywhich returns a DateTimewith all of the time-related fields cleared out.

C# 没有Date类型,但DateTimes 确实有一个Date属性,它返回一个DateTime清除所有与时间相关的字段。

Specifically it returns:

具体来说,它返回:

A new object with the same date as this instance, and the time value set to 12:00:00 midnight (00:00:00).

与此实例具有相同日期的新对象,并且时间值设置为午夜 12:00:00 (00:00:00)。

VB.NET does have a Datetype but it is equivalent to a CLR DateTime

VB.NET 确实有一个Date类型,但它相当于一个 CLRDateTime