rowlandsfc
Active member
so i have created a basic game, it has a simple scoring system where the score and player name(both variables) is saved to a text file, leaderboard.text. i have an issue with sorting the file by the score and not the name, i cant get it to work .``
i can supply any other code if needed
thats the code ive tried but i get the error on the list<int> line that it is not in the correct format.
if anyone can steer me in the right direction that would be great
C#:
// reads the leaderboard txt and displays it in listbox
private void scoreBoard()
{
List<string> lines = File.ReadLines(@"E:\College Year 3\Computer Programming 2\Minefield\Leaderboard.txt").ToList();
List<int> score = lines.Select(s => Convert.ToInt32(s)).ToList();
score.Sort();
foreach (int r in score)
{
listBox1.Items.Add(r);
}
}
i can supply any other code if needed
thats the code ive tried but i get the error on the list<int> line that it is not in the correct format.
if anyone can steer me in the right direction that would be great