This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Why is it a best practice to open files using the using statement in C#?
It makes the file open faster.
It converts the file contents into an array of strings.
It automatically closes the file when the block finishes, even if an error occurs.
Which File method overwrites a file's existing content?
File.AppendAllText()
File.ReadAllText()
File.WriteAllText()
What does File.ReadAllLines() return?
A single string containing the entire file.
An array of strings, one for each line in the file.
The number of lines in the file.
What does StreamReader.ReadLine() return once there are no more lines to read?
An empty string
It throws an exception.
null
You must answer all questions before checking your work.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?