A constructor is a special method that runs when an object is created and sets up its state. It has the class name and no return type.
A default constructor takes no parameters. The compiler adds one only when the class declares no constructor.
A parameterized constructor takes values to initialize the object.
A static constructor initializes static members. It runs once per type, before first use.
A private constructor stops outside code from creating instances, as in a singleton.
C# has no built-in copy constructor, so you write one yourself.
public class Person
{
// Parameterized constructor
public Person(string name, int age)
{
Name = name;
Age = age;
}
// Static constructor
static Person()
{
// Initialize static members
}
}
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The diagram below the answer is the concept .
Jump to it ↓
Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:
Saved in this browser - sign in to keep your review list.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Keep going - a few more words and AI can grade it.
Interview lens
How interviewers actually use this question
Likely follow-ups
How do this(...) and base(...) work, and in what order do the constructors run?this(...) reuses another constructor in the same class, base(...) picks which base constructor runs, and the base body runs before the derived body.
When exactly does a static constructor run, and what happens if it throws?It runs once per type, before the first instance or static member access, and you never call it. If it throws, you get TypeInitializationException.
How would you use a private constructor to build a thread-safe singleton?Use a private constructor and one static instance, made safe with a static readonly field or Lazy<T>. An unlocked null check is not thread-safe.
Why is it risky to call a virtual method from a constructor?The override runs before the derived constructor body, so it can read fields that body has not set yet. Keep constructors to plain setup.
What you can say
A constructor is a special method that runs when you create an object, and its job is to set up that object's state.
It has the same name as the class and no return type, not even void.
A default constructor takes no parameters, and a parameterized one takes the values the object needs, like a Person that needs a name and an age.
A static constructor sets up static members, and it runs once per type, before the type is first used.
A private constructor stops outside code from creating instances, which is how you build a singleton.
One catch is that the compiler adds a default constructor only when you declare none, and C# has no built-in copy constructor, so you write that one yourself.
Weak answers to avoid
Claims there is always a default constructorThe compiler adds one only when the class declares no constructor. Add a parameterized one and new Person() stops compiling unless you write a parameterless one too.
Claims C# has a built-in copy constructorIt has none. Assigning a class variable copies the reference, not the object, so you write a copy constructor yourself when you need an independent copy.
Vague about when a static constructor runsSay it runs once per type, before first use, and code never calls it. Saying it runs for every object shows you have not used one.
Lists the types with no reason to use themGive each one a job, such as a private constructor for a singleton or a parameterized one so an object never exists half set up.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.