VariantWrapper(Object) 构造函数

定义

为指定的VariantWrapper参数初始化类的新实例Object

public:
 VariantWrapper(System::Object ^ obj);
public VariantWrapper(object obj);
public VariantWrapper(object? obj);
new System.Runtime.InteropServices.VariantWrapper : obj -> System.Runtime.InteropServices.VariantWrapper
Public Sub New (obj As Object)

参数

obj
Object

要封送的对象。

示例

下面的代码示例演示如何使用 VariantWrapper 类包装 Object 互操作封送器传递的传递方式 VT_VARIANT | VT_BYREF

// Create an instance of an unmanged COM object.
UnmanagedComClass UnmanagedComClassInstance = new UnmanagedComClass();

// Create a string to pass to the COM object.
string helloString = "Hello World!";

// Wrap the string with the VariantWrapper class.
object var = new System.Runtime.InteropServices.VariantWrapper(helloString);

// Pass the wrapped object.
UnmanagedComClassInstance.MethodWithStringRefParam(ref var);
' Create an instance of an unmanged COM object.
Dim UnmanagedComClassInstance As New UnmanagedComClass()

' Create a string to pass to the COM object.
Dim helloString As String = "Hello World!"

' Wrap the string with the VariantWrapper class.
Dim var As Object = New System.Runtime.InteropServices.VariantWrapper(helloString)

' Pass the wrapped object.
UnmanagedComClassInstance.MethodWithStringRefParam(var)

适用于