2
Answers

construction order

George George

George George

16y
2k
1

Hello everyone,


For the following code, it is correct to say that,

1. obj1 will be instialized when .NET Runtime loads class Foo and before any instance is created?

2. obj2 will be created each time we create an instance of Foo, and obj2 will be called before constructor?

My question is whether my understanding (1) and (2) are correct?

[Code]
class Foo
{
    static private object obj1 = new object();
    private object obj2 = new object();
    public Foo()
    {
    }
}
[/Code]


thanks in advance,
George

Answers (2)