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

后端 未结 13 1915
暗喜
暗喜 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条回答
  •  日久生厌
    2020-11-28 10:40

    In addition to Robert's answer you also have the DateTime.ToShortDateString method. Also, if you really wanted a Date object you could always use the Adapter pattern and wrap the DateTime object exposing only what you want (i.e. month, day, year).

提交回复
热议问题