public static void SetNextItem(string[,] HighScores, int ScoreNo) { for (int i = HighScores.GetLength(0) - 1; i > ScoreNo; i--) { HighScores[i, 0] = HighScores[i - 1, 0]; HighScores[i, 1] = HighScores[i - 1, 1]; } }
private void Score_Load(object sender, EventArgs e) { listBox1.Items.Clear(); listBox1.SelectionMode = SelectionMode.None; int scoresAmount = Tools.countScores(); // Create a new array for blackjack scores string[,] blackjackScores = new string[scoresAmount, 2]; // Populate the blackjack scores array Tools.ScoreArray(blackjackScores); // Sort the blackjack scores in descending order blackjackScores = Tools.HighScoreArray(blackjackScores); // Display the top 5 scores in the list box for (int i = 0; i < 5 && i < blackjackScores.GetLength(0); i++) { string username = blackjackScores[i, 0]; string score = blackjackScores[i, 1]; listBox1.Items.Add($"{username}:\t {score}\n"); } }