Export (0) Print
Expand All

VariantWrapper Constructor

Initializes a new instance of the VariantWrapper class for the specified System.Object parameter.

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

public VariantWrapper(
	Object obj
)

Parameters

obj
Type: System.Object

The object to marshal.

The following code example demonstrates how to use the VariantWrapper class to wrap an Object that the interop marshaler passes as 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);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1
Show:
© 2015 Microsoft