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

  • Home
  • SEARCH
  • 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 591407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:37:53+00:00 2026-05-13T15:37:53+00:00

If I have a function void Foo(params int[] bar){} The following runs fine: int[]

  • 0

If I have a function

void Foo(params int[] bar){}

The following runs fine:

int[] a1 = {1, 2, 3};
int[] a2 = {4, 5, 6};
Foo(1, 2, 3);
Foo(a1);

But these give compile errors:

Foo(a1, 1, 2, 3);
Foo(1, 2, a1);
Foo(1, a1, 2);
Foo(a1, a2, 1, 2, 3);

because only the first argument is allowed to be an int[], the rest have to be ints.

The final example is what I would like to do, but the language won’t let me without combining the arrays first. I really like the simplicity of the syntax, and I would rather not add to the code more than I have to. Does anyone have a nice way to do this?

  • 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-13T15:37:53+00:00Added an answer on May 13, 2026 at 3:37 pm

    It’s weird. Foo(a1, 2, 3) shouldn’t work. You should either pass an array or a bunch of integers. You can’t mix them AFAIK. Do you have another overload or something?

    There’s not really a neat syntax for doing that. The most concise one I can think of is:

    Foo(a1.Concat(a2).Concat(new[] {1,2,3}).ToArray());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following intentionally trivial function: void ReplaceSome(ref string text) { StringBuilder sb
I have a function pointer defined by: typedef void (*EventFunction)(int nEvent); Is there a
I have seen a function whose prototype is: int myfunc(void** ppt) This function is
I have a function called: void initializeJSP(string Experiment) And in my MyJSP.h file I
i have a function like void printMe (void *i) { printf(%d, i); } where
I have a function in a native DLL defined as follows: #include <string> void
I have a function that takes pointer to pointer to struct. struct ABC; void
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
If I have a method such as: private function testMethod(param:string):void { // Get the
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035

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.