Question:You need to read the entire contents of a file named Message.txt into a single string variable. Which code segment should you use? 

A string result = null;
StreamReader reader = new StreamReader("Message.txt"); result = reader.ReadLine(); 

B string result = string.Empty;
StreamReader reader = new StreamReader("Message.txt"); while (!reader.EndOfStream) {
result += reader.ToString();
} 

C string result = null;
StreamReader reader = new StreamReader("Message.txt"); result = reader.Read().ToString(); 

D string result = null;
StreamReader reader = new StreamReader("Message.txt"); result = reader.ReadToEnd(); 

+ Answer
+ Report
Total Preview: 1185

Copyright © 2024. Powered by Intellect Software Ltd