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 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)
{
}
C++:
void Test(...)
{
//use va_list, va_start,va_arg, and va_end to access the parameter array
}
Java:
void Test(Object... myParamArray)
{
}
Copyright © 2004 – 2024 Tangible Software Solutions, Inc.