File.AppendAllText(path, (usernameforscore + " " + classicscore + Environment.NewLine));
using (StreamReader reader = new StreamReader(path))
{
string line;
while((line = reader.ReadLine())!=null)
{
if (line.IndexOf("Score") != -1) line = line.ToUpper();
string[] sub = line.Split(" ");
Console.WriteLine(line);
}
I currently have this set of code to store and display a set of highscores, "usernameforscore" is a string previously inputted and "classicscore" is an integer previously calculated. Currently, it will write in as I want it to (for example - [Dom 9] would be in the file) , the display however just does it in the exact order of the file. My question is, is there a way to both order the outputting of these lines in a file by the highest "classicscore" variable.
Also, is there a way for it to also check for duplicate names before outputting it so it only gives the highest score of each person.
I'm using C# on Visual Studio.