A type for Date only in C# - why is there no Date type?

后端 未结 13 1890
暗喜
暗喜 2020-11-28 10:23

In our C# project we have the need for representing a date without a time. I know of the existence of the DateTime, however, it incorporates a time of day as well. I

13条回答
  •  -上瘾入骨i
    2020-11-28 10:55

    Why? We can only speculate and it doesn't do much to help solve engineering problems. A good guess is that DateTime contains all the functionality that such a struct would have.

    If it really matters to you, just wrap DateTime in your own immutable struct that only exposes the date (or look at the DateTime.Date property).

提交回复
热议问题