Bird
0
0

What does the File.ReadAllLines method return when called on a text file?

easy🧠 Conceptual Q2 of 15
C Sharp (C#) - File IO
What does the File.ReadAllLines method return when called on a text file?
AA string containing the entire file content
BA StreamReader object
CA byte array of the file content
DAn array of strings, each representing a line
Step-by-Step Solution
Solution:
  1. Step 1: Identify the return type of File.ReadAllLines

    File.ReadAllLines reads all lines and returns them as a string array.
  2. Step 2: Compare with other options

    File.ReadAllText returns a string, File.ReadAllBytes returns byte array, and StreamReader is a different class.
  3. Final Answer:

    An array of strings, each representing a line -> Option D
  4. Quick Check:

    ReadAllLines returns string[] = B [OK]
Quick Trick: ReadAllLines splits file by lines into string array [OK]
Common Mistakes:
MISTAKES
  • Thinking it returns a single string
  • Confusing with ReadAllText
  • Expecting a StreamReader object

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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