Difficulty: Easy
Correct Answer: A constructor can be a static constructor.
Explanation:
Introduction / Context:
Constructors in C#.NET initialize objects and set up type-level state. In addition to ordinary instance constructors, the language also supports a special kind called a static constructor, which runs once per type to initialize static members.
Given Data / Assumptions:
Concept / Approach:
There are two broad constructor categories in C#: instance constructors (can be overloaded, can be private/protected/internal/public) and static constructors (no parameters, no access modifiers, run automatically once, and initialize static data). An instance constructor executes with an implicit this
reference and can read/write both instance and static members. Static constructors have no this
and can touch only static state.
Step-by-Step Solution:
this
; it refers to the object under construction.
Verification / Alternative check:
Compile a class with a private constructor (compiles) and with multiple overloads (compiles). Add a static constructor to set static fields (compiles and runs once at first use).
Why Other Options Are Wrong:
this
exists in instance constructors; only static constructors lack it.
Common Pitfalls:
Confusing static constructors (type initialization) with instance constructors (object initialization).
Final Answer:
A constructor can be a static constructor.
Discussion & Comments