public bool DoesScoreAlreadyExist(PlayerScore scoreToChcek) { if (PlayerScoresListContainer.PlayerScoresRanked.Exists(x => x.Name == scoreToChcek.Name)) { return(true); } else { return(false); } }
private void AddScoreToRankedList(string player, int currentScore) { var score = new PlayerScore(player, currentScore); if (DoesScoreAlreadyExist(score)) { //we remove a score if it already exists so we can updated it //you might not need this maybe you just want to keep adding scores PlayerScoresListContainer.PlayerScoresRanked.RemoveAll(x => x.Name == score.Name); PlayerScoresListContainer.PlayerScoresRanked.Add(score); } else { PlayerScoresListContainer.PlayerScoresRanked.Add(score); } }