Error del compilador CS0637

Actualización: noviembre 2007

Mensaje de error

El atributo FieldOffset no se permite en campos static ni const
The FieldOffset attribute is not allowed on static or const fields

El atributo FieldOffset no se puede usar en campos marcados como static o const.

El código siguiente genera el error CS0637:

// CS0637.cs
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Explicit)]
public class MainClass
{
   [FieldOffset(3)]   // CS0637
   public static int i;
   public static void Main ()
   {
   }
}