Bird
0
0

Inside a constructor, what does the this keyword allow you to do in C#?

easy🧠 Conceptual Q2 of 15
C Sharp (C#) - Classes and Objects
Inside a constructor, what does the this keyword allow you to do in C#?
ARefer to the base class constructor
BAccess static members only
CCreate a new instance of the class
DCall another constructor in the same class
Step-by-Step Solution
Solution:
  1. Step 1: Understand constructor chaining

    The this keyword can be used to call another constructor in the same class to avoid code duplication.
  2. Step 2: Differentiate from base constructor calls

    Calling a base class constructor uses the base keyword, not this.
  3. Final Answer:

    Call another constructor in the same class -> Option D
  4. Quick Check:

    this() in constructor = call same class constructor [OK]
Quick Trick: Use this() to chain constructors [OK]
Common Mistakes:
MISTAKES
  • Confusing this() with base()
  • Trying to use this to create new instances
  • Using this to access static members in constructor

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes