title: Trying to get a valid integer from keyboard input
body: <p>I am trying to get a valid integer from the user input, the function I wrote must display an error message for these inputs..</p>
  
  <p>1) 0 or a negative number</p>
  
  <p>2) a string </p>
  
  <p>It works for strings but not for 0 or negative numbers</p>
  
  <p>I am unable to find my mistakes.. :-(</p>
  
  <pre><code> public int getValidNumber()
      {
          int temp_int;
          while ((!int.TryParse(Console.ReadLine(), out temp_int)) &amp;&amp; (temp_int &gt; 0))
          {
              Console.WriteLine("Not a valid number....try again");
          }
          return temp_int;
      }
  </code></pre>
  
  <p>Is it the correct way to use  temp_int  variable immediately....?</p>