title: C# Guessing Game - Windows Form App - How to configure a 'PlayAgainButton' and keep total score
body: <p>I'm new with c# and I need some help with my little app. </p>
  
  <p>I want to have a button which starts the game over again after you are done, but the program needs to keep the total score. (you receive points for guessing)</p>
  
  <p>Thanks in advance,</p>
  
  <p>Philip</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace GuessingGame
  {
   public partial class TheUltimateGuessingGame : Form
   {
  
      public TheUltimateGuessingGame()
      {
          InitializeComponent();
      }
  
      int number;
      int numberoftries;
      int points;
      int total = 0;
      private void Form1_Load(object sender, EventArgs e)
      {
  
          Random generator = new Random();
          number = generator.Next(0, 101);
  
          MessageBox.Show("Try to guess a number between 1 and 100");
      }
  
      private void PlayAgainButton_Click(object sender, EventArgs e)
      {
          InitializeComponent();
      }
  
      private void button_guess_Click(object sender, EventArgs e)
      {
          int guess = Convert.ToInt32(textBox_guess.Text);
  
          if (guess &gt; number)
          {
              textbox_showdifference.Text = ("Guess was too high, try again!");
          }
  
          if (guess &lt; number)
          {
              textbox_showdifference.Text = ("Guess was too low, try again!");
          }
  
          if (guess == number)
          {
              textbox_showdifference.Text = ("Awesome, guess was right!");
  
              MessageBox.Show("It took you " + Convert.ToString(numberoftries) + " tries 
              to guess the right number");
  
              if (numberoftries &lt;= 3)
              {
                  points = 10;
              }
  
              if (numberoftries &gt;= 4 &amp;&amp; numberoftries &lt;= 6)
              {
                  points = 5;
              }
  
              if (numberoftries &gt;= 7)
              {
                  points = 2;
              }
  
              total = total + points;
  
              ScoreBoard1.Text = ("Here are your points --&gt; " + points + "\nHere are your total points --&gt; " + total);
          }
          ++numberoftries;
  
  
      }
  
       private void exitbutton_Click(object sender, EventArgs e)
      {
          Application.Exit();
      }
  
  }
  </code></pre>
  
  <p>}</p>