DateOnly Type in C# - The correct way to store Date in #csharp

preview_player
Показать описание
I’ve seen so many dotnet developers making this mistake

When you have to store a Date value without time, some devs are still use the DateTime object.

This is wrong.

Instead, use the DateOnly object that was introduced in .NET6

You can get today's date from DateTime.Now and convert that object into a DateOnly object and that will remove the time component for you.

You can also have a meaningful date and new it up using the DateOnly object.

Formatting a DateOnly object is the same as the DateTime object, just add the.ToString method and pass the date format that you would like to have.

There’s a similar concept for TimeOnly too.

#dotnet #csharp #coding

Рекомендации по теме
Комментарии
Автор

Bhai bht zabardast MashaAllah ❣️

Please create a tutorial about authentication & authorization .Net framework

faizudesigns
Автор

Awesome content You just have to be consistent.

MohammedMufish_Shaikh