Complete the code to open a file for reading.
using System.IO;
var file = new StreamReader([1]);
The file name must be a string in quotes to open it correctly.
Complete the code to write text to a file.
using System.IO; using var writer = new StreamWriter([1]); writer.WriteLine("Hello World");
To write to a file, provide the file name as a string to StreamWriter.
Fix the error in the code to read all lines from a file.
string[] lines = File.[1]("log.txt");
Use ReadAllLines to read all lines from a file into a string array.
Fill both blanks to create a dictionary with word lengths for words longer than 3 characters.
var lengths = new Dictionary<string, int> { { [1], [2] } };The key is a word string and the value is its length as an integer.
Fill all three blanks to read a file, count lines longer than 5 characters, and print the count.
var lines = File.[1]("data.txt"); int count = lines.[2](line => line.Length > [3]); Console.WriteLine(count);
ReadAllLines reads all lines, Count counts lines matching the condition, and 5 is the length threshold.
