共用方式為


編譯器錯誤 C3270

'field': FieldOffset 屬性只可以使用在 StructLayout(Explicit) 的內容中,在此情況下為必要項目

備註

欄位已標示為 FieldOffset,只有在 StructLayout(Explicit) 生效時,才允許此字段。

Example

下列範例會產生 C3270:

// C3270_2.cpp
// compile with: /clr /c
using namespace System::Runtime::InteropServices;

[ StructLayout(LayoutKind::Sequential) ]
// try the following line instead
// [ StructLayout(LayoutKind::Explicit) ]
public value struct MYUNION
{
   [FieldOffset(0)] int a;   // C3270
   // ...
};