Ошибка компилятора CS0636
Обновлен: Ноябрь 2007
Сообщение об ошибке
Атрибут "FieldOffset" можно помещать только в члены типов, помеченных атрибутом StructLayout(LayoutKind.Explicit)
The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)
Необходимо применить атрибут StructLayout(LayoutKind.Explicit) в объявлении структуры, если она содержит любые типы, помеченные атрибутом FieldOffset. Дополнительные сведения см. в разделе FieldOffset.
Следующий пример приводит к возникновению ошибки 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 ()
{
}
}