✅ Help with non-nullable field must contain a non-null value when exiting constructor.
Following an online tutorial and trying to resolve nullable reference warnings (the tutorial was before nullable reference types were introduced).
I have a
The error is regarding the backing field
Furthermore the
So my question is, why am I still getting the warning and what is the best approach to fixing it?
As I understand it, the compiler already knows that
TIA
I have a
GameSession class with the constructor defined as The error is regarding the backing field
private Location _currentLocation which is set using the property Furthermore the
LocationAt method is non-nullable defined as So my question is, why am I still getting the warning and what is the best approach to fixing it?
As I understand it, the compiler already knows that
LocationAt will return a Location and the backing field _currentLocation should be set by the CurrentLocation property in the constructor. Why does it still think currentLocation is null when exiting constructor?TIA