MarshalAsAttribute.MarshalTypeRef 字段

定义

MarshalType 作为类型实现。

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

字段值

属性

注解

可以使用 MarshalTypeRefMarshalType 字段为特性化参数、字段或返回类型指定自定义封送处理器类型。 字段 MarshalTypeRef 通过缩短语法可以更轻松地使用 MarshalType 。 在以下示例中,第一行表示 使用 MarshalType 的语法,第二行表示使用 的 MarshalTypeRef语法。

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

可以使用 Type C#、 GetType Visual Basic 或 typeid C++ 设置对象typeof。 有关创建和使用自定义封送处理程序的其他信息,请参阅 自定义封送处理

适用于

另请参阅