System.Runtime.InteropServices.MarshalAsAttribute.MarshalTypeRef Field

Implements MarshalAsAttribute.MarshalType as a type.

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public Type MarshalTypeRef

Remarks

You can use either the MarshalAsAttribute.MarshalTypeRef or MarshalAsAttribute.MarshalType field to specify a custom marshaler type for the attributed parameter, field, or return type. The MarshalAsAttribute.MarshalTypeRef field allows easier usage of MarshalAsAttribute.MarshalType by shortening the syntax. In the following example, the first line represents syntax using MarshalAsAttribute.MarshalType and the second line represents syntax using MarshalAsAttribute.MarshalTypeRef.

Example

[MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Assembly, NameSpace.TypeName")] 

Example

[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NameSpace.TypeName)]

You can set a Type object using typeof in C#, GetType in Visual Basic, or typeid in C++. For additional information about creating and using custom marshalers, see Custom Marshaling.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0