Represents a variable argument list. You can use this class to step through the argument list of a function that takes a variable number of arguments. It is very likely that most compilers will hide the complexity of ArgIterator under language syntax. See the example below.
Functions that require variable length argument lists are declared using the ellipsis (...) in the argument list.
[Visual Basic] Public Structure ArgIterator [C#] public struct ArgIterator [C++] public __value struct ArgIterator
[JScript] In JScript, you can use the structures in the NGWS frameworks, but you cannot define your own.
[To be supplied.]
Namespace: System
Assembly: mscorlib.dll
Managed C++:
#import <mscorlib.dll> #include <crt.h> int sum(int numElements,...) { va_list args; va_start(args, numElements); //Creates a new ArgIterator int sum = 0; int arg; for(int ct=0;ct < numElements;ct++) { arg = va_arg(args, int); //Calls ArgIterator::GetNextArg() Console::WriteLine (L"Argument {0}: '{1}'", Int32::Box(ct), Int32::Box(arg)); sum += arg; } return sum; } int main() { int ret = sum(4, 40, 54, 20, 99); Console::WriteLine (L"Sum is: {0}", Int32::Box(ret)); return 1; }