Search code examples
c#app-configapplication-settings

How to save a int in Visual Studio?


I want to save a int like this:

Properties.Settings.Default.Score = ScoreInt;

So when I reopen the app (it's a clicker game) the int should be the one the player has made.


Solution

  • Add an event handler for closing your app and add the call

    Properties.Settings.Default.Save();
    

    And in the program startup do the assignment like Robert placed in the comments

    ScoreInt = Properties.Settings.Default.Score;