I have an asp.net core MVC application, and I'm using an if statement for conditional rendering.
In the following code snippet:
if (@item.Date.HasValue)
{
<div>
<text>@Common.DateConverter.GetHijriDateString(item.Date.Value)</text>
</div>
}
Why is it throwing a (InvalidOperationException: Nullable object must have a value.) exception, if the value is null, even though I have placed a check for null value in the enclosing if statement?