Bird
Raised Fist0

Which interface must a resource implement to be used inside a using statement in C#?

easy🧠 Conceptual Q2 of Q15
C Sharp (C#) - Exception Handling
Which interface must a resource implement to be used inside a using statement in C#?
AIEnumerable
BIDisposable
CICloneable
DIComparable
Step-by-Step Solution
Solution:
  1. Step 1: Identify the interface for resource cleanup

    The using statement requires the resource to implement IDisposable to call Dispose automatically.
  2. Step 2: Check other interfaces

    IEnumerable is for collections, ICloneable for copying, IComparable for sorting, none relate to cleanup.
  3. Final Answer:

    IDisposable -> Option B
  4. Quick Check:

    using requires IDisposable = B [OK]
Quick Trick: using needs IDisposable interface implemented [OK]
Common Mistakes:
MISTAKES
  • Choosing IEnumerable or other unrelated interfaces
  • Not knowing IDisposable is for cleanup
  • Confusing IDisposable with other interfaces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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