Compare commits

..

2 Commits

Author SHA1 Message Date
ca98a852e5 Merge pull request 'remove null warnings' (#1) from fixnull into master
Reviewed-on: #1
2024-10-22 11:42:02 +00:00
Marcin Badurowicz
a277aaeb93 reove null warnings 2024-10-22 13:37:34 +02:00

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>();