title: Binary String to Integer
body: <p>I have a binary string, entered by the user, which I need to convert to an integer.</p>
  <p>At first, I naively used this simple line:</p>
  <pre><code>Convert.ToInt32(&quot;11011&quot;,2);
  </code></pre>
  <p>Unfortunately, this throws an exception if the user enters the integer directly.</p>
  <pre><code>Convert.ToInt32(&quot;123&quot;,2); // throws Exception
  </code></pre>
  <p>How can I make sure that the string entered by the user actually is a binary string?</p>
  <ul>
  <li><code>try..catch</code></li>
  <li><code>Int32.TryParse</code></li>
  </ul>
  <p>Thanks</p>