コンパイラ エラー CS0636
更新 : 2007 年 11 月
エラー メッセージ
FieldOffset 属性は StructLayout(LayoutKind.Explicit) に指定された型のメンバでのみ使用できます。
FieldOffset 属性でマークされたメンバが含まれている構造体の宣言では、StructLayout(LayoutKind.Explicit) 属性を使用する必要があります。詳細については、「FieldOffsetAttribute クラス」を参照してください。
次の例では CS0636 エラーが生成されます。
// CS0636.cs
using System;
using System.Runtime.InteropServices;
// To resolve the error, uncomment the following line:
// [StructLayout(LayoutKind.Explicit)]
struct Worksheet
{
[FieldOffset(4)]public int i; // CS0636
}
public class MainClass
{
public static void Main ()
{
}
}