title: C# method generic params parameter bug?
body: <p>I appears to me as though there is a bug/inconsistency in the C# compiler.</p>
  
  <p>This works fine (first method gets called):</p>
  
  <pre><code>public void SomeMethod(string message, object data);
  public void SomeMethod(string message, params object[] data);
  
  // ....
  SomeMethod("woohoo", item);
  </code></pre>
  
  <p>Yet this causes "The call is ambiguous between the following methods" error:</p>
  
  <pre><code>public void SomeMethod&lt;T&gt;(string message, T data);
  public void SomeMethod&lt;T&gt;(string message, params T[] data);
  
  // ....
  SomeMethod("woohoo", (T)item);
  </code></pre>
  
  <p>I could just use the dump the first method entirely, but since this is a very performance sensitive library and the first method will be used about 75% of the time, I would rather not always wrap things in an array and instantiate an iterator to go over a foreach if there is only one item.</p>
  
  <p>Splitting into different named methods would be messy at best IMO.</p>
  
  <p>Thoughts?</p>
  
  <p>EDIT:</p>
  
  <p>I guess Andrew might be onto something.</p>
  
  <p>Full example:</p>
  
  <pre><code>public static class StringStuffDoer
  {
      public static string ToString&lt;T&gt;(T item1, T item2)
      {
          return item2.ToString() + item1.ToString();
      }
  
      public static string ToString&lt;T&gt;(T item, params T[] items)
      {
          StringBuilder builder = new StringBuilder();
  
          foreach (T currentItem in items)
          {
              builder.Append(currentItem.ToString());
          }
  
          return item.ToString() + builder.ToString();
      }
  
      public static void CallToString()
      {
          ToString("someString", null); // FAIL
          ToString("someString", "another string"); // SUCCESS
          ToString("someString", (string)null); // SUCCESS
      }
  }
  </code></pre>
  
  <p>I still think it is odd that the cast is needed - the call is not ambiguous.  It works if you replace T with string or object or any non-generic type, so why wouldn't it work for the generic? It properly finds the two possible matching methods, so I believe that by the spec, it should pick the one that doesn't use params if possible.  Correct me if I'm wrong here.</p>
  
  <p>(NOT SO) FINAL UPDATE:</p>
  
  <p>Sorry for taking you guys on this tyraid, I've apparently been staring at this too long...too much looking at generics and params for one night.  The non-generic version throws the ambiguous error as well, I just had the method signature off in my mockup test.</p>
  
  <p>REAL FINAL UPDATE:</p>
  
  <p>Okay, this is why the problem didn't show up in my non-generic test.  I was using "object" as the type parameters.  SomeMethod(object) and SomeMethod(params object[]) do NOT throw the ambiguous error, I guess "null" automatically gets cast to "object". A bit strange I'd say, but somewhat understandable, maybe.</p>
  
  <p>So, oddly enough, this call DOES work:</p>
  
  <pre><code>SomeMethod&lt;object&gt;("someMessage", null);
  </code></pre>