Search code examples
c#.netvariablessave

Save variable c# .net


how can i save a variable in c# (.net), i need this to save the score! And when i start the game again, the variable is the same as before. And here is the variable Please help me find a very simple way. I tried to find something about that in the web but its way to coplycated for me.

int Wins;

//CODE for saving Variable

label5.Text = "Matches won:" + Wins;

Sorry for my Bad English

Thank you!


Solution

  • The best thing I think you should do is to store your data in a file. I suggest considering JSON - it is very popular now.

    You can work with the System.Text.Json namespace which is supported by Microsoft. You can find some example and useful guide in the Mirosoft guide.

    Or you can work with Newtonsoft.JSON package here.