title: Best way to check string and convert to int in c#
body: <p>Please help me to improve my code.
  The idea is:
   if string is ok 
      then convert to int</p>
  
  <p>1- it does check just null or blank string</p>
  
  <pre><code>int t=0;
   if(!string.IsNullOrEmpty(textbox1.text.trim())
       t= int.Parse(textbox1.text.trim());
  </code></pre>
  
  <p>2-   </p>
  
  <pre><code>if(int.tryparse(textbox1.text.trim(), out t)      
     t=int.Parse(textbox1.text.trim());
  </code></pre>
  
  <p>or shortif</p>
  
  <pre><code> return string.IsNullOrEmpty(textbox1.text.trim()) ? 0 :  int.Parse(textbox1.text.trim());
  </code></pre>
  
  <p>is there other better way?</p>