title: If statement inside an if statement c#
body: <p>I have written a console application to print when a user enters a number. When a user press 1, the console prints the text specified in the corresponding <code>if</code> statement. How do I get this working? </p>
  
  <pre><code>int keypress; // Variable to hold number
  
  ConsoleKeyInfo UserInput = Console.ReadKey(); // Get user input
  
  // We check input for a Digit
  if (char.IsDigit(UserInput.KeyChar))
  {
      keypress = int.Parse(UserInput.KeyChar.ToString()); // use Parse if it's a Digit
  
      if (keypress = 1)
      {
          Console.WriteLine("6$ Cheese added to your cart");
  
      }
      else (keypress = 2){
  
          Console.WriteLine("2$ Bread added to your cart");
      }
       else (keypress = 3){
  
          Console.WriteLine("1$ cookie added to your cart");
      }
  
  }
  
  else
  {
      keypress = -1;  // Else we assign a default value
      Console.WriteLine("Number you entered isn't in the grocery list, please retry");
  }
  </code></pre>