System.Runtime.InteropServices.MarshalAsAttribute.MarshalTypeRef Field

Implements MarshalAsAttribute.MarshalType as a type.


public Type MarshalTypeRef


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.


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


[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.


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