title: Generate Random number in C#
body: <p>I am wanting to generate a random number between 1 and 10. Yet I am getting a couple of errors.</p>
  
  <pre><code>public Form1()
  {
      InitializeComponent();
  }
  int randomNumber = (0, 11);
  int attempts = 0;
  
  public int RandomNumber
  {
      get
      {
          return randomNumber;
      }
  
      set
      {
          randomNumber = value;
      }
  }
  </code></pre>
  
  <p>it is all on the 0, 11 under the comma is says --> struct System.Int32 represents a 32-bit signed integer &lt;--. Under the 11 it says --> Identifier expected Syntax error, ',' expected &lt;--. Now if I just have like int randomNumber = 0; then it will work fine, still have multiple guesses and the guess count adds up like it should, and have the too high too low labels. just the number will always be 0.</p>
  
  <p>Also how can I make it to where I don't have to click the guess button, I can just hit enter on the keyboard? </p>
  
  <pre><code>private void button1_Click_1(object sender, EventArgs e)
  {
      try
      {
          if (int.Parse(textBox1.Text) &gt; RandomNumber) label1.Text = "Too high.";
  
          else if (int.Parse(textBox1.Text) &lt; RandomNumber) label1.Text = "Too low.";
          else
          {
              label1.Text = "You won.";
              textBox1.Enabled = false;
              label2.Text = "Attempts: 0";
              textBox1.Text = String.Empty;
              MessageBox.Show("You won in " + attempts + " attempts, press generate to play again.", "Winner!");
              attempts = 0;
              label2.Text = "Attempts: " + attempts.ToString();
              return;
          }
          attempts++;
          label2.Text = "Attempts: " + attempts.ToString();
      }
      catch { MessageBox.Show("Please enter a number."); }
  }
  </code></pre>