gpt4 book ai didi

c# - 采用 DateTime 值并仅接受时间,反之亦然

转载 作者:太空狗 更新时间:2023-10-30 00:55:19 25 4
gpt4 key购买 nike

我目前正在开发一个用作待办事项列表的应用程序,我想知道如何从日期时间框中接受一个值,但只使用日期值或时间值。我目前正在这样做。

DateTime ted = appointmentDateTimeDate.Value; //The date
DateTime at = appointmentDateTimeTime.Value; //The time

我应该换一种方式吗?

最佳答案

使用DateTime.Date日期属性和 DateTime.TimeOfDay时间:

DateTime ted = appointmentDateTimeDate.Date; //The date
TimeSpan at = appointmentDateTimeTime.TimeOfDay; //The time

关于c# - 采用 DateTime 值并仅接受时间,反之亦然,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9977470/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com