reove null warnings

This commit is contained in:
Marcin Badurowicz 2024-10-22 13:37:34 +02:00
parent bbd11ec870
commit a277aaeb93

View File

@ -25,10 +25,12 @@ var name = Console.ReadLine() ?? "";
var hs = new HighScore { Name = name, Trials = trials };
List<HighScore> highScores = null;
List<HighScore>? highScores = null;
const string FileName = "highscores.json";
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)
highScores = new List<HighScore>();