S
Stephen Lamb
Does anyone know if the standard has anything to say about how static fields
that use other static fields in initialization behave? Pointers into the
standard would be most appreciated. Thanks.
public struct SomeStruct
{
public SomeStruct(int i)
{
I = i;
}
public int I;
}
public struct S1
{
public static SomeStruct S = new SomeStruct(1);
}
public struct S2
{
public static SomeStruct S = new SomeStruct(S1.I);
}
(p.s. Sorry if this doesn't compile, I don't have a compiler from my posting
location.)
Is S2.S.I guaranteed to be 1, 0, or undefined? Does the order in which the
structs are declared change the outcome? If SomeStruct is a class, does
that affect the outcome? If S1.S and S2.S are readonly, does that affect
the outcome? If S1 and S2 are in different namespace, assemblies, etc.?
I've seen instances where S2.S.I == 0 in MSVC 7.1 .NET 1.1 under the
debugger (and the debugger is not displaying 0 when the actual value is 1,
the value really is 0).
Thanks,
Steve
that use other static fields in initialization behave? Pointers into the
standard would be most appreciated. Thanks.
public struct SomeStruct
{
public SomeStruct(int i)
{
I = i;
}
public int I;
}
public struct S1
{
public static SomeStruct S = new SomeStruct(1);
}
public struct S2
{
public static SomeStruct S = new SomeStruct(S1.I);
}
(p.s. Sorry if this doesn't compile, I don't have a compiler from my posting
location.)
Is S2.S.I guaranteed to be 1, 0, or undefined? Does the order in which the
structs are declared change the outcome? If SomeStruct is a class, does
that affect the outcome? If S1.S and S2.S are readonly, does that affect
the outcome? If S1 and S2 are in different namespace, assemblies, etc.?
I've seen instances where S2.S.I == 0 in MSVC 7.1 .NET 1.1 under the
debugger (and the debugger is not displaying 0 when the actual value is 1,
the value really is 0).
Thanks,
Steve