Bird
0
0

Why is it important to close a file after performing file operations in C#?

easy🧠 Conceptual Q1 of 15
C Sharp (C#) - File IO
Why is it important to close a file after performing file operations in C#?
ATo make the file read-only automatically
BTo free system resources and avoid file locks
CTo delete the file from the disk
DTo convert the file format to binary
Step-by-Step Solution
Solution:
  1. Step 1: Understand file resource management

    When a file is opened, system resources are allocated to handle it.
  2. Step 2: Importance of closing files

    Closing the file releases these resources and prevents other programs from being blocked.
  3. Final Answer:

    To free system resources and avoid file locks -> Option B
  4. Quick Check:

    File closing importance = Free resources and avoid locks [OK]
Quick Trick: Always close files to free resources and prevent locks [OK]
Common Mistakes:
MISTAKES
  • Assuming files close automatically without explicit call
  • Thinking closing deletes the file
  • Believing closing changes file format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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