MarshalAsAttribute 建構函式

定義

初始化 MarshalAsAttribute 類別的新執行個體。

多載

MarshalAsAttribute(Int16)

使用指定的 UnmanagedType 值,初始化 MarshalAsAttribute 類別的新執行個體。

MarshalAsAttribute(UnmanagedType)

使用指定的 MarshalAsAttribute 列舉型別 (Enumeration) 成員,初始化 UnmanagedType 類別的新執行個體。

MarshalAsAttribute(Int16)

來源:
MarshalAsAttribute.cs
來源:
MarshalAsAttribute.cs
來源:
MarshalAsAttribute.cs

使用指定的 UnmanagedType 值,初始化 MarshalAsAttribute 類別的新執行個體。

C#
public MarshalAsAttribute(short unmanagedType);

參數

unmanagedType
Int16

要將資料封送處理成的值。

備註

這個建構函式會採用基礎 16 位帶正負號的整數,代表每個 UnmanagedType 列舉成員。 Tlbimp.exe (類型庫匯入工具) 會使用此建構函式。

另請參閱

適用於

.NET 10 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

MarshalAsAttribute(UnmanagedType)

來源:
MarshalAsAttribute.cs
來源:
MarshalAsAttribute.cs
來源:
MarshalAsAttribute.cs

使用指定的 MarshalAsAttribute 列舉型別 (Enumeration) 成員,初始化 UnmanagedType 類別的新執行個體。

C#
public MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType unmanagedType);

參數

unmanagedType
UnmanagedType

要將資料封送處理成的值。

備註

對於較不容易出錯的可讀取程序代碼,請一律使用此建構函式。

另請參閱

適用於

.NET 10 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0