I have this code:
DateTime now = DateTime.Now; // null
decimal noon = 0m;
int dayOfYear = now.DayOfYear; // reports 98, correct
bool isAM = false;
if (dayOfYear >= 80 && dayOfYear <= 260)
{
noon = 13m;
int h = now.Hour; // 0 (should be 15)
isAM = now.Hour >= 13 ? false : true; // true (should be false)
}
in Blazor webassembly in a component, When I debug, While 'now' variable is null the 'dayOfYear' variable correctly shows 98, But 'now.Hour' is 0, And the correct computer time is 3:30 PM, Why 'now' variable is null? And how it correctly reports dayOfYear 98? why Hour is 0!? I am using Blazor 3.2 using its new debugging capability.
Update: The hour is correct, Only the DateTime object's 'null' value put me in doubt as the following screenshot shows:

nowvariable can't possibly be null - it's a non-nullable value type. This sounds like a debugger issue. - Jon Skeetnow.Hour,now.Minute,now.DayOfYearetc, along with sample output (and what the current time is when you run it). (But no,DateTime.Hourshould not be affected by formatting.) - Jon Skeet