Erreur du compilateur CS0625
Mise à jour : novembre 2007
Message d'erreur
'champ' : les types de champ d'instance marqués avec StructLayout(LayoutKind.Explicit) doivent posséder un attribut FieldOffset
'field': instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute
Lorsqu'un struct est marqué avec un attribut StructLayout explicite, tous les champs du struct doivent avoir l'attribut FieldOffset. Pour plus d'informations, consultez StructLayoutAttribute, classe.
L'exemple suivant génère l'erreur CS0625 :
// CS0625.cs
// compile with: /target:library
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit)]
struct A
{
public int i; // CS0625 not static; an instance field
}
// OK
[StructLayout(LayoutKind.Explicit)]
struct B
{
[FieldOffset(5)]
public int i;
}