remove null warnings #1

Merged
marcinb merged 1 commits from fixnull into master 2024-10-22 11:42:03 +00:00
Showing only changes of commit a277aaeb93 - Show all commits

View File

@ -25,10 +25,12 @@ var name = Console.ReadLine() ?? "";
var hs = new HighScore { Name = name, Trials = trials }; var hs = new HighScore { Name = name, Trials = trials };
List<HighScore> highScores = null; List<HighScore>? highScores = null;
const string FileName = "highscores.json"; const string FileName = "highscores.json";
if (File.Exists(FileName)) if (File.Exists(FileName))
highScores = JsonSerializer.Deserialize<List<HighScore>>(File.ReadAllText(FileName)); highScores =
JsonSerializer.Deserialize<List<HighScore>>(File.ReadAllText(FileName))
?? new List<HighScore>();
if (highScores == null) if (highScores == null)
highScores = new List<HighScore>(); highScores = new List<HighScore>();