通过


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 。 在下面的示例中,第一行表示 using MarshalType 语法,第二行表示使用语法 MarshalTypeRef

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

可以使用 C# 中的 typeofGetType Visual Basic 或 C++ 中的 typeid 设置 Type 对象。

适用于

另请参阅