How do I save an object list to the computer as XML when I close the program, and load it when I open the progam again?
This is my test code with the object list I want to save, and then load when I open the program again:
public class HighScore
{
public string name;
public int points;
public HighScore(string N, int P)
{
this.name = N;
this.points = P;
}
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string name;
public static int points;
public static List<HighScore> scorem = new List<HighScore>();
private void Form1_Load(object sender, EventArgs e)
{
scorem.Add(new HighScore("Paul", 20));
scorem.Add(new HighScore("Robert", 30));
scorem.Add(new HighScore("John", 35));
scorem.Add(new HighScore("Steph", 25));
scorem.Add(new HighScore("Seth", 40));
scorem.Add(new HighScore("Johnny", 55));
scorem.Add(new HighScore("Michael", 200));
scorem.Add(new HighScore("Robertinoe", 300));
scorem.Add(new HighScore("Marstrand", 2500));
scorem.Add(new HighScore("Doe", 3000));
scorem = scorem.OrderByDescending(x => x.points).ToList();
foreach(HighScore per in scorem)
{
label1.Text += per.name + " " + per.points + "\n";
}
}