Quirks when using overloaded methods with params string[] and inheritance
<p>I had a class like this</p>

<pre><code>public class Child
{
    public string ToXml()
    {
        return "Child : ToXml()";
    }

    public string ToXml( params string[] fields )
    {
        return "Child : ToXml(...)";
    }
}
</code></pre>

<p>creating an instances of class Child and calling ToXml() returns the first overloaded function which was fine and dandy.</p>

<pre><code>var obj = new Child();
Console.WriteLine( obj.ToXml() );
</code></pre>

<p>Output:</p>

<pre><code>Child : ToXml()
</code></pre>

<p>But when I added a Parent class and changed the Child class to this :</p>

<pre><code>public class Parent
{
    public virtual string ToXml()
    {
        return "Parent : ToXml()";
    }
}

public class Child : Parent
{
    public override string ToXml()
    {
        return "Child : ToXml()";
    }

    public string ToXml( params string[] fields )
    {
        return "Child : ToXml(...)";
    }
}
</code></pre>

<p>The output has changed to this :</p>

<pre><code>Child : ToXml(...)
</code></pre>

<p>My question is, why is the behaviour like this? (I'm using VS2010 using .NET 3.5)</p>

<p>I kind of 'fixed' this problem by changing the second overloaded function to this : (I took out the <i>params</i> keyword</p>

<pre><code>public class Child : Parent
{
    public override string ToXml()
    {
        return "Child : ToXml()";
    }

    public string ToXml( string[] fields )
    {
        return "Child : ToXml(...)";
    }
}
</code></pre>

<p>Which brings me to my second question (let me know if I should split this to 2 different post), what is the difference between the functions</p>

<pre><code>ToXml( params string[] fields )
</code></pre>

<p>and</p>

<pre><code>ToXml( string[] fields )
</code></pre>

<p>They both seems to work when I call the functions like so :</p>

<pre><code>var obj = new Child();
Console.WriteLine( obj.ToXml( new [] { "foo", "bar" ) );
</code></pre>
