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 917125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:09:36+00:00 2026-05-15T18:09:36+00:00

Say I have the following methods: public static void MyCoolMethod(params object[] allObjects) { }

  • 0

Say I have the following methods:

public static void MyCoolMethod(params object[] allObjects)
{
}

public static void MyCoolMethod(object oneAlone, params object[] restOfTheObjects)
{
}

If I do this:

MyCoolMethod("Hi", "test");

which one gets called and why?

  • 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-15T18:09:36+00:00Added an answer on May 15, 2026 at 6:09 pm

    It’s easy to test – the second method gets called.

    As to why – the C# language specification has some pretty detailed rules about how ambiguous function declarations get resolved. There are lots of questions on SO surrounding interfaces, inheritance and overloads with some specific examples of why different overloads get called, but to answer this specific instance:

    C# Specification – Overload Resolution

    7.5.3.2 Better function member

    For the purposes of determining the
    better function member, a
    stripped-down argument list A is
    constructed containing just the
    argument expressions themselves in the
    order they appear in the original
    argument list.

    Parameter lists for each of the
    candidate function members are
    constructed in the following way:

    • The expanded form is used if
      the function member was applicable
      only in the expanded form.

    • Optional parameters with no
      corresponding arguments are removed
      from the parameter list

    • The parameters are reordered
      so that they occur at the same
      position as the corresponding argument
      in the argument list.

    And further on…

    In case the parameter type sequences {P1, P2, …, PN} and {Q1, Q2, …, QN} are equivalent > (i.e. each Pi has an identity conversion to the corresponding Qi), the following
    tie-breaking rules are applied, in order, to determine the better function member.

    • If MP is a non-generic method and MQ is a generic method, then MP is better than MQ.

    • Otherwise, if MP is applicable in its normal form and MQ has a params array and is
      applicable only in its expanded form, then MP is better than MQ.

    • Otherwise, if MP has more declared parameters than MQ, then MP is better than MQ.
      This can occur if both methods have params arrays and are applicable only in their
      expanded forms.

    The bolded tie-breaking rule seems to be what is applying in this case. The specification goes into detail about how the params arrays are treated in normal and expanded forms, but ultimately the rule of thumb is that the most specific overload will be called in terms of number and type of parameters.

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

Sidebar

Ask A Question

Stats

  • Questions 501k
  • Answers 501k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer One nice way is with a custom selector. Something like… May 16, 2026 at 2:08 pm
  • Editorial Team
    Editorial Team added an answer we know .pem - (Privacy Enhanced Mail) Base64 encoded DER… May 16, 2026 at 2:08 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately, there isn't a configurable way to prevent that. Every… May 16, 2026 at 2:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Say I have: class A { public: static void DoStuff(); // ... more methods
Say I have a method like this: public void SaveData() { try { foreach
Let's say I have the following text file: This is the first line of
Let's say I have the following two classes: public class Person { public string
Lets say i have a form which have the following : Name:TextBox Email:TextBox Age:TextBox
Say I have the following JS: var foo_index = 123; var bar_index = 456;
Say I have the following code: struct date { int day; int month; int
Let's say I have the following two tables: Fields FieldID INT FieldName NVARCHAR(50) Values
I want to be able to write extension methods so that I can say:
I have a web service in which I am manipulating POST and GET methods

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.