you cannot control the initialization order of a static variable. If you really want this, you must do this in a static constructor:
static class XYZ{ private static int field1; private static int field2; static XYZ { field1 = - 1; field2 = field1 + 1; } public static string Sum() { prop1 = 10; Debug.WriteLine(field2); } }
As John said, I was mistaken in my assumption.
source share