Export (0) Print
Expand All

ArgIterator Constructor (RuntimeArgumentHandle, Void*)

Initializes a new instance of the ArgIterator structure using the specified argument list and a pointer to an item in the list.

This constructor is not CLS-compliant.  

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

[CLSCompliantAttribute(false)] 
public ArgIterator (
	RuntimeArgumentHandle arglist,
	void* ptr
)
J# does not support APIs that consume or return unsafe types.
JScript does not support APIs that consume or return unsafe types.

Parameters

arglist

An argument list consisting of mandatory and optional arguments.

ptr

A pointer to the argument in arglist to access first, or the first mandatory argument in arglist if ptr is a null reference (Nothing in Visual Basic).

The new ArgIterator object enumerates the argument list starting from the argument specified by ptr, or the first mandatory argument if ptr is a null reference (Nothing in Visual Basic).

Notes to Implementers This constructor is provided specifically for use with the C/C++ programming language.

The following code example demonstrates the ArgIterator constructor.

// This code example demonstrates the ArgIterator constructor.
using System;

public class Sample
{
public static void Main()
    {
    // Call a method with a variable argument list.
    int i=0;
    Test.printArg( (double)23.7, ref i, 
                   __arglist( typeof(int), "hello", UIntPtr.Zero ) );
    }
}

public class Test
{
    public unsafe static void printArg(double d, ref int i, __arglist)
    {

    // Get the argument list, starting at the first argument.
    ArgIterator args = new ArgIterator( __arglist, null);

/*
    // Get the argument list, starting at the first optional argument.
    ArgIterator args = new ArgIterator( __arglist );
*/

    // Display the type of each argument in the argument list.
    TypedReference tr;
    while(true)
        {
        try {
            tr = args.GetNextArg();
            Console.WriteLine( TypedReference.GetTargetType(tr) );
            }
        catch ( InvalidOperationException ) 
            { 
            break; 
            }
        }
    }
}

/* 
This code example produces the following results if you use 
"new ArgIterator( __arglist, null)":

System.Double
System.Int32
System.Type
System.String
System.UIntPtr

This code example produces the following results if you use 
the commented statement, "new ArgIterator(__arglist)":

System.Type
System.String
System.UIntPtr

*/

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft