MarshalAsAttribute.MarshalTypeRef 字段

定义

MarshalType 作为类型实现。Implements MarshalType as a type.

public: Type ^ MarshalTypeRef;
public Type MarshalTypeRef;
[System.Runtime.InteropServices.ComVisible(true)]
public Type MarshalTypeRef;
val mutable MarshalTypeRef : Type
Public MarshalTypeRef As Type 

字段值

属性

注解

您可以使用 "MarshalTypeRef" 或 "MarshalType" 字段为属性化参数、字段或返回类型指定自定义封送处理程序类型。You can use either the MarshalTypeRef or MarshalType field to specify a custom marshaler type for the attributed parameter, field, or return type. 通过缩短语法,"MarshalTypeRef" 字段允许更轻松地使用 MarshalTypeThe MarshalTypeRef field allows easier usage of MarshalType by shortening the syntax. 在下面的示例中,第一行表示使用 MarshalType 的语法,第二行表示使用 MarshalTypeRef的语法。In the following example, the first line represents syntax using MarshalType and the second line represents syntax using MarshalTypeRef.

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

您可以使用中的 typeof 设置 Type 对象C#,GetType 在中 Visual Basic 或 typeid C++。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.

适用于

另请参阅