• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

Parameter Arrays in C#, VB, C++, and Java

Most programming languages have syntax which allows passing a variable number of arguments to a method, when the actual number of arguments is unknown at compile time.  In each of the following cases, 'myParamArray' can be accessed within the method like an ordinary array, except for the native C++ case which uses special library calls to access the parameter array.

C#:

void Test(params object[] myParamArray)
{
}

VB:

Sub Test(ParamArray ByVal myParamArray() As Object)
{
}

Native C++:

void Test(...)
{
    //use va_list, va_start,va_arg, and va_end to access the parameter array
}

C++/CLI:

void Test(... array<System::Object^> ^myParamArray)
{
}

Java:

void Test(Object... myParamArray)
{
}

Copyright © 1997 – 2017 Tangible Software Solutions Inc.