ParameterModifier 结构

定义

将修饰符附加到参数,以便绑定可与在其中修改了类型的参数签名一起使用。Attaches a modifier to parameters so that binding can work with parameter signatures in which the types have been modified.

public value class ParameterModifier
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct ParameterModifier
type ParameterModifier = struct
Public Structure ParameterModifier
继承
ParameterModifier
属性

示例

下面的代码示例演示具有三个字符串参数的成员, 其中第一个和第三个参数是通过引用传递的。The following code example shows this for a member that has three string arguments, the first and third of which are passed by reference. 假定名obj为的变量包含对 COM 对象的引用。Assume that a variable named obj contains a reference to the COM object.

// Create an array containing the arguments.
array<Object^>^ args = {"Argument 1", "Argument 2", "Argument 3" };

// Initialize a ParameterModifier with the number of parameters.
ParameterModifier p = ParameterModifier(3);

// Pass the first and third parameters by reference.
p[0] = true;
p[2] = true;

// The ParameterModifier must be passed as the single element
// of an array.

array<ParameterModifier>^ mods = { p };

// Invoke the method late bound.
obj->GetType()->InvokeMember("MethodName", BindingFlags::InvokeMethod,
     nullptr, obj, args, mods, nullptr, nullptr);
// Create an array containing the arguments.
object[] args = {"Argument 1", "Argument 2", "Argument 3" };

// Initialize a ParameterModifier with the number of parameters.
ParameterModifier p = new ParameterModifier(3);

// Pass the first and third parameters by reference.
p[0] = true;
p[2] = true;

// The ParameterModifier must be passed as the single element
// of an array.
ParameterModifier[] mods = { p };

// Invoke the method late bound.
obj.GetType().InvokeMember("MethodName", BindingFlags.InvokeMethod,
     null, obj, args, mods, null, null);
' Create an array containing the arguments.
Dim args As Object = {"Argument 1", "Argument 2", "Argument 3" }

' Initialize a ParameterModifier with the number of parameters.
Dim p As New ParameterModifier(3)

' Pass the first and third parameters by reference.
p(0) = True
p(2) = True

' The ParameterModifier must be passed as the single element
' of an array.
Dim mods() As ParameterModifier = { p }

' Invoke the method late bound.
obj.GetType().InvokeMember("MethodName", BindingFlags.InvokeMethod, _
     Nothing, obj, args, mods, Nothing, Nothing)

注解

在将参数按引用传递Type.InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])给后期绑定访问的 COM 组件时,结构与方法重载一起使用。ParameterModifierThe ParameterModifier structure is used with the Type.InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]) method overload when passing parameters by reference to a COM component that is accessed late bound. 要通过引用传递的参数由单个ParameterModifier结构指定, 该结构必须在包含单个元素的数组中传递。The parameters that are to be passed by reference are specified by a single ParameterModifier structure, which must be passed in an array containing a single element. 此数组ParameterModifier中的单个结构必须用要调用的成员中的参数数目来初始化。The single ParameterModifier structure in this array must be initialized with the number of parameters in the member that is to be invoked. 若要指示通过引用传递这些参数中的哪些参数, 请将Item[Int32]属性的值 (中C#的索引器true ) 设置为与参数的从零开始的位置对应的索引号。To indicate which of these parameters are passed by reference, set the value of the Item[Int32] property (the indexer in C#) to true for the index number corresponding to the zero-based position of the parameter.

构造函数

ParameterModifier(Int32)

初始化表示指定参数数量的 ParameterModifier 结构的新实例。Initializes a new instance of the ParameterModifier structure representing the specified number of parameters.

属性

Item[Int32]

获取或设置一个值,该值指定当前 ParameterModifier 是否修改位于指定索引位置的参数。Gets or sets a value that specifies whether the parameter at the specified index position is to be modified by the current ParameterModifier.

适用于