Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C#
C# Reference
C# Compiler Options
C# Compiler Errors
 Compiler Error CS0625
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual C# Reference: Errors and Warnings 
Compiler Error CS0625 

Error Message

'field': instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute

When a struct is marked with an explicit StructLayout attribute, all fields in the struct must have the FieldOffset attribute. For more information, see StructLayoutAttribute Class.

The following sample generates 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;
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker