This code has the well defined behavior in C# of not working:
class Foo
{
static List<int> to = new List<int>( from ); // from is still null
static IEnumerable<int> from = Something();
}
Note: I'm not asking how to fix that code as I already known how to do that
What is the justification for this? C# already does run time checks to detect the first access to static members. Why not extend this to a per member thing and have them run on demand or even better have the compiler figure out the order at compile time?
BTW: I think the same question (or almost the same) also holds for non static members.