Bird
0
0

What does the Clear() method do in a StringBuilder instance?

easy🧠 Conceptual Q2 of 15
C Sharp (C#) - Strings and StringBuilder
What does the Clear() method do in a StringBuilder instance?
ARemoves the last character only
BResets the capacity to default
CDeletes all characters, resetting length to zero
DAppends an empty string
Step-by-Step Solution
Solution:
  1. Step 1: Understand Clear() method purpose

    The Clear() method removes all characters from the StringBuilder, making its length zero.
  2. Step 2: Differentiate from other options

    It does not remove just one character, reset capacity, or append text. It fully clears content.
  3. Final Answer:

    Deletes all characters, resetting length to zero -> Option C
  4. Quick Check:

    Clear() empties StringBuilder = Deletes all characters [OK]
Quick Trick: Clear() empties StringBuilder content instantly [OK]
Common Mistakes:
MISTAKES
  • Thinking Clear() removes only last char
  • Confusing Clear() with capacity reset

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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