C# DateTime: What “date” to use when I'm using just the “time”?

后端 未结 12 1563
陌清茗
陌清茗 2020-12-16 09:35

I\'m using a DateTime in C# to display times. What date portion does everyone use when constructing a time?

E.g. the following is not valid because ther

12条回答
  •  醉梦人生
    2020-12-16 10:40

    How about DateTime.Now.TimeOfDay, and use the TimeSpan?

    Re "because that doesn't store times of the day." - well, it does if you think of a TimeSpan as the time since midnight.

    A "duration", for example, screams TimeSpan.

提交回复
热议问题