title: Parse an integer from a string with trailing garbage
body: <p>I need to parse a decimal integer that appears at the start of a string.</p>
  
  <p>There may be trailing garbage following the decimal number.  This needs to be ignored (even if it contains other numbers.)</p>
  
  <p>e.g.</p>
  
  <pre><code>"1" =&gt; 1
  " 42 " =&gt; 42
  " 3 -.X.-" =&gt; 3
  " 2 3 4 5" =&gt; 2
  </code></pre>
  
  <p>Is there a built-in method in the .NET framework to do this?</p>
  
  <p><code>int.TryParse()</code> is not suitable.  It allows trailing spaces but not other trailing characters.</p>
  
  <p>It would be quite easy to implement this but I would prefer to use the standard method if it exists.</p>