Bird
0
0

Why is it important to use a using statement with StreamReader or StreamWriter in C#?

hard🧠 Conceptual Q10 of 15
C Sharp (C#) - File IO
Why is it important to use a using statement with StreamReader or StreamWriter in C#?
AIt automatically closes and disposes the stream to free resources
BIt speeds up file reading and writing
CIt encrypts the file contents during access
DIt allows multiple threads to access the file simultaneously
Step-by-Step Solution
Solution:
  1. Step 1: Understand resource management

    Streams hold system resources that must be released after use.
  2. Step 2: Role of using statement

    Using statement ensures Dispose() is called automatically, closing the stream.
  3. Final Answer:

    It automatically closes and disposes the stream to free resources -> Option A
  4. Quick Check:

    Using = automatic disposal of streams [OK]
Quick Trick: Use using to auto-close streams and free resources [OK]
Common Mistakes:
MISTAKES
  • Thinking using speeds up IO
  • Assuming using encrypts data
  • Believing using enables multithreading

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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