How to remove time portion of date in C# in DateTime object only?

后端 未结 30 3748
醉话见心
醉话见心 2020-11-22 09:08

I need to remove time portion of date time or probably have the date in following format in object form not in the form of string.

         


        
30条回答
  •  不要未来只要你来
    2020-11-22 09:44

    You can't. A DateTime in .NET always have a time, defaulting to 00:00:00:000. The Date property of a DateTime is also a DateTime (!), thus having a time defaulting to 00:00:00:000 as well.

    This is a shortage in the .NET Framework, and it could be argued that DateTime in .NET violates the Single Responsibility Principle.

提交回复
热议问题