New C# DateOnly and TimeOnly

Опубликовано: 27 Июль 2026
на канале: filteredCode
2,966
25

Finally we can represent our intent more clearly by having these 2 new types. DateOnly allows us to represent a date without time, without timezones. Also TimeOnly is an improvement on TimeSpan where we can represent a time in the day.

At the time of recording .NET 6 is still in preview. To get it up an running you'll need to install .NET 6: https://dotnet.microsoft.com/download...

You'll also need to enable "Preview feature" in Visual Studio. Go to Tools - Options - Environment - Preview Features - Enable "Use Previews of the .NET Core SDK" option.