Instead of using DateTime for storing dates or times separately in .NET, use the DateOnly and TimeOnly types. DateOnly represents dates without time components, while TimeOnly represents times without dates. This approach clarifies intent, reduces confusion from ignoring components or creating arbitrary values, and improves code maintainability. Both types can be converted to and from DateTime when needed.
•1m watch time
2 Comments
Sort: