Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6897935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:13:55+00:00 2026-05-27T07:13:55+00:00

I had a class like this public class Child { public string ToXml() {

  • 0

I had a class like this

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

    public string ToXml( params string[] fields )
    {
        return "Child : ToXml(...)";
    }
}

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

var obj = new Child();
Console.WriteLine( obj.ToXml() );

Output:

Child : ToXml()

But when I added a Parent class and changed the Child class to this :

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(...)";
    }
}

The output has changed to this :

Child : ToXml(...)

My question is, why is the behaviour like this? (I’m using VS2010 using .NET 3.5)

I kind of ‘fixed’ this problem by changing the second overloaded function to this : (I took out the params keyword

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

    public string ToXml( string[] fields )
    {
        return "Child : ToXml(...)";
    }
}

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

ToXml( params string[] fields )

and

ToXml( string[] fields )

They both seems to work when I call the functions like so :

var obj = new Child();
Console.WriteLine( obj.ToXml( new [] { "foo", "bar" ) );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:13:56+00:00Added an answer on May 27, 2026 at 7:13 am

    For your first question, this is by design:

    For example, the set of candidates for a method invocation does not include methods marked override (Section 7.3), and methods in a base class are not candidates if any method in a derived class is applicable (Section 7.5.5.1).

    For your second question, a params modifier make that parameter act as a varargs parameter, meaning it can receive multiple parameters comma-separated, and the array is created implicitly by the compiler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I had a viewmodel that looked something like this public class AddressViewModel {
If I had a class in Java like this: public class Test { //
I had View strongly type of my class Usario Defined like this public partial
I had a function like this, that wasn't within a class: // Gets the
Like this: public class remoteStatusCounts : RemoteStatus { public int statusCount; public remoteStatusCounts(RemoteStatus r)
I have a couple classes that look like this public class ParentClass { public
I have a class like this: public final class Foo { public native int
I have a class like this: public class myClass { public List<myOtherClass> anewlist =
I have a class hierarchy like this public abstract class CalendarEventBase{} public class TrainingEvent
I have a class hierachy like this public class A { protected class B

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.