ParameterModifier 结构

定义

将修饰符附加到参数,以便绑定可与在其中修改了类型的参数签名一起使用。

C#
public readonly struct ParameterModifier
C#
public struct ParameterModifier
C#
[System.Serializable]
public struct ParameterModifier
C#
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct ParameterModifier
继承
ParameterModifier
属性

示例

下面的代码示例演示了具有三个字符串参数的成员的这一点,其中第一个和第三个参数通过引用传递。 假设名为 的 obj 变量包含对 COM 对象的引用。

C#
// 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);

注解

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

构造函数

ParameterModifier(Int32)

初始化表示指定参数数量的 ParameterModifier 结构的新实例。

属性

Item[Int32]

获取或设置一个值,该值指定当前 ParameterModifier 是否修改位于指定索引位置的参数。

适用于

产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.5, 1.6, 2.0, 2.1