Lets say I have 2 classes:
public abstract class Foo
{
static Foo()
{
print("4");
}
}
public class Bar : Foo
{
static Bar()
{
print("2");
}
static void DoSomething()
{
/*...*/
}
}
I expected that after calling Bar.DoSomething()
(assuming this is the first time I access the Bar class) the order of event will be:
- Foo's static constructor (again, assuming first access) > print
4
- Bar's static constructor > print
2
- Execution of
DoSomething
At the bottom line I expect 42
to be printed.
After testing, it seems that only 2
is being printed.
And that is not even an answer.
Can you explain this behavior?