Compiler Warning (level 3) CS0282

There is no defined ordering between fields in multiple declarations of partial class or struct 'type'. To specify an ordering, all instance fields must be in the same declaration.

To resolve this error, put all member variables in a single partial class definition.

A common way to get this error is by having a partial struct defined in more than one place, with some of the member variables in one definition, and some in another.

The following code generates CS0282.

Example 1

This code contains one description of a struct. Compile these two modules together in a single step by means of the command:

csc /target:library cs0282_1.cs cs0282_2.cs

partial struct A
{
    int i;
}

Example 2

This code contains a conflicting description of the same struct.

partial struct A
{
    int j;
}

Note

If the struct layout does not matter, decorating the struct with [StructLayout(LayoutKind.Auto)] will express it,and suppress the warning