Bird
0
0

Which of the following is the correct way to open a file for reading using StreamReader?

easy📝 Syntax Q3 of 15
C Sharp (C#) - File IO
Which of the following is the correct way to open a file for reading using StreamReader?
AStreamReader.Open("file.txt")
Bnew StreamReader.Read("file.txt")
Cnew StreamReader("file.txt")
DStreamReader.ReadFile("file.txt")
Step-by-Step Solution
Solution:
  1. Step 1: Recall StreamReader constructor

    StreamReader is instantiated with the file path as a string argument.
  2. Step 2: Check syntax correctness

    Only new StreamReader("file.txt") is valid syntax to open a file for reading.
  3. Final Answer:

    new StreamReader("file.txt") -> Option C
  4. Quick Check:

    StreamReader open syntax = new StreamReader(path) [OK]
Quick Trick: Use new StreamReader("filename") to open files [OK]
Common Mistakes:
MISTAKES
  • Using method calls instead of constructor
  • Confusing StreamReader with static methods
  • Incorrect method names like ReadFile or Open

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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