Practice mode C#

When does a static constructor run in C#?

Correct answer B. Once, automatically, before the first instance is created or any static member is accessed

Explanation

A static constructor initialises static data. The runtime calls it at most once per type, before the first instance is created or any static member is referenced. It takes no parameters and no access modifiers, and it cannot be called directly. If it throws, the type becomes unusable for the rest of the application domain, raising TypeInitializationException.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.