title: How to make a Generic Type Cast function
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3502493/is-there-a-generic-parse-function-that-will-convert-a-string-to-any-type-using">is there a generic Parse() function that will convert a string to any type using parse?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to make a generic function for doing some operations, like:</p>
  
  <pre><code>ConvertValue&lt;T&gt;(string value)
  </code></pre>
  
  <p>If <code>T</code> is <code>int</code> then the function will convert the value to <code>int</code> and return the result.</p>
  
  <p>Similarly, if <code>T</code> is <code>boolean</code>, the function will convert the <code>value</code> to <code>boolean</code> and return it.</p>
  
  <p>How to write this?</p>