Warning: NULL literal or a possible NULL value is being converted to a non-nullable type.
Ladies and gentlemen,
I am confronted with a new type of warning, that I would like to understand.
What should I do?
This is the code:
This is the message:
NULL literal or a possible NULL value is being converted to a non-nullable type
3 Replies
what should I do ?? 😦
FirstOrDefaultAsync
will return the first item matching the predicate, or default
if nothing matches
default for a reference type is null
that means you are assingning null
to User user
, which is declared as non-nullable
you must either change this to use First
so it never returns null, or change the return value to Task<User?>
if its intended that null is an acceptable return valueThank you.
again!