Bird
0
0

Which method of StreamWriter is used to write a line of text to a file?

easy🧠 Conceptual Q2 of 15
C Sharp (C#) - File IO
Which method of StreamWriter is used to write a line of text to a file?
AReadLine()
BWriteLine()
CWriteText()
DAppendLine()
Step-by-Step Solution
Solution:
  1. Step 1: Identify StreamWriter methods

    StreamWriter provides Write() and WriteLine() methods to write text.
  2. Step 2: Select method for writing a line

    WriteLine() writes text followed by a newline, suitable for lines.
  3. Final Answer:

    WriteLine() -> Option B
  4. Quick Check:

    StreamWriter line write = WriteLine() [OK]
Quick Trick: Use WriteLine() to write text with a newline [OK]
Common Mistakes:
MISTAKES
  • Using ReadLine() which is for reading
  • Assuming WriteText() exists
  • Confusing AppendLine() with WriteLine()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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