title: Why can 'int' be treated as 'ushort' but not when passed as a parameter in an extension method and what's an elegant solution to it?
body: <p>I have this extension method:</p>
  
  <pre><code>public static bool In&lt;T&gt;(this T source, params T[] list)
  {
      return list.Contains(source);
  }
  </code></pre>
  
  <p>Now I need to use the above method for a <code>ushort</code>. When I try</p>
  
  <pre><code>ushort p = 3;
  if (p.In(1, 2, 3, 4, 5))
     return;
  </code></pre>
  
  <p>The first line casts <code>3</code> to a <code>ushort</code> well. But when <code>3</code> is passed as a parameter, I get the error</p>
  
  <blockquote>
    <p>'ushort' does not contain a definition for 'In' and the best extension method overload 'Extensions.In(T, params T[])' has some invalid arguments.</p>
  </blockquote>
  
  <p>But this works:</p>
  
  <pre><code>ushort p = 3;
  if (Extensions.In(p, 1, 2, 3, 4, 5))
     return;
  </code></pre>
  
  <p>which is weird. </p>
  
  <ol>
  <li><p>Why does it work with the second example, but not the first?</p></li>
  <li><p>What's a good alternative that would help me here? Since there are no literals for <code>short</code> or <code>ushort</code> I'm failing to find a simpler alternative than manually casting each integer like this:</p>
  
  <pre><code>ushort p = 3;
  if (p.In((ushort)1, (ushort)2, (ushort)3, (ushort)4, (ushort)5))
     return;
  </code></pre></li>
  </ol>