GetNativeVariantForObject Method (Object, IntPtr)

Marshal.GetNativeVariantForObject Method (Object, IntPtr)


Converts an object to a COM VARIANT.

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

public static void GetNativeVariantForObject(
	object obj,
	IntPtr pDstNativeVariant


Type: System.Object

The object for which to get a COM VARIANT.

Type: System.IntPtr

A pointer to receive the VARIANT that corresponds to the obj parameter.

Exception Condition

The obj parameter is a generic type.

The pDstNativeVariant parameter must point to sufficient memory to store the resulting VARIANT. Also, the implementation of this method calls the VariantInit function on the raw memory that the pDstNativeVariant parameter points to.


requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft