I am developing a C# Winform app in .NET CF 3.5 environment.
I understand that a TypeInitializationException occurs in the example below.
static int [] ArrayB = new int [ArrayA.Length];
static int [] ArrayA = new int [] {1, 2, 3, 4};
This is because ArrayA is null when ArrayB is declared. Therefore, there is no error if you change it as shown below.
static int [] ArrayA = new int [] {1, 2, 3, 4};
static int [] ArrayB = new int [ArrayA.Length];
So why does not the following example throw a TypeInitializationException?
static int [] ArrayB = new int [len];
static int len = 4;
ArrayB is declared before len. I think that an error should occur because len is not yet initialized when declaring ArrayB.
But why does not the error occur?