title: Select parsed int, if string was parseable to int
body: <p>So I have an <code>IEnumerable&lt;string&gt;</code> which can contain values that can be parsed as <code>int</code>, as well as values that cannot be.</p>
  
  <p>As you know, <code>Int32.Parse</code> throws an exception if a string cannot be changed to an int, while <code>Int32.TryParse</code> can be used to check and see if the conversion was possible without dealing with the exception. </p>
  
  <p>So I want to use a LINQ query to one-liner parse those strings which can be parsed as int, without throwing an exception along the way. I have a solution, but would like advice from the community about whether this is the best approach.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>int asInt = 0;
  var ints = from str in strings
             where Int32.TryParse(str, out asInt)
             select Int32.Parse(str);
  </code></pre>
  
  <p>So as you can see, I'm using <code>asInt</code> as a scratch space for the call to <code>TryParse</code>, just to determine if <code>TryParse</code> would succeed (return bool). Then, in the projection, I'm actually performing the parse. That feels ugly.</p>
  
  <p>Is this the best way to filter the parseable values in one-line using LINQ?</p>