Generic class can product identical signature overloads?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3679562/generic-methods-and-method-overloading">Generic methods and method overloading</a>  </p>
</blockquote>



<p>Ok, I hit this one by accident... Giving this situation:</p>

<pre><code>class Program {
    static void Main( string[ ] args ) {

        var obj = new gen&lt;int&gt;( );
        Console.Write( obj[ 1 ] );
        Console.ReadKey( );

    }
}

class gen&lt;T&gt; {

    public int this[ T i ] { get { return 2; } }

    public int this[ int i ] { get { return 1; } }

}
</code></pre>

<p>It will always print 1. I would have expected for the compiler to complain, or the runtime to crash and burn and melt the CPU, but no, it is happy to print '1'</p>

<p>Of course I can make a choice to return either if I use any other type for the generic parameter. For giggles, I try using UInt as the generic type parmater, and I can differentiate between the calls, so the questions are:</p>

<ol>
<li><p>Why C# does not freak out? Shouldn't Anders Hejlsberg feel a disturbance in the force?</p></li>
<li><p>How can I restrict a generic parameter from certain types? As in this T can be anything but ints (but long are OK)</p></li>
</ol>
