title: Dependent Types in C#: making the output type depend on the input value
body: <p>I want to be able to make a method, in C#, whose output type depends on its argument value; loosely,</p>
  
  <p><code>delegate B(a) DFunc&lt;A,B&gt;(A a);</code></p>
  
  <p>As an example, I'd like to write a function which takes an integer and returns one of many possible types depending on the argument:</p>
  
  <pre><code>f(1) = int
  f(2) = bool
  f(3) = string
  f(n), where n &gt;= 4 = type of n-by-n matrices
  </code></pre>
  
  <p>Any help would be useful. </p>