ParameterModifier 结构

在参数中附加修饰符,以便绑定能够处理在其中修改了类型的参数签名。

**命名空间:**System.Reflection
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Structure ParameterModifier
用法
Dim instance As ParameterModifier
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public struct ParameterModifier
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public value class ParameterModifier
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class ParameterModifier extends ValueType
JScript 支持使用结构,但不支持进行新的声明。

备注

当通过对后期绑定访问的 COM 组件的引用传递参数时,ParameterModifier 结构和 Type.InvokeMember 方法重载一起使用。将通过引用传递的参数由单个 ParameterModifier 结构指定,而该结构必须在包含单个元素的数组中传递。必须用要调用的成员中的参数数目来初始化此数组中的单个 ParameterModifier 结构。若要指示这些参数中的哪些参数将通过引用传递,对于与此参数的从零开始的位置相对应的索引号,请将 Item 属性(C# 中的索引器)的值设置为 true

下面的 Visual Basic 和 C# 代码演示了一个成员(它有三个字符串参数,第一个和第三个参数通过引用传递)的上述行为。假定一个名为 obj 的变量包含对 COM 对象的引用。

    ' 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)
    // 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);

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

ParameterModifier 成员
System.Reflection 命名空间