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 = nullptr;StreamReader^ reader = gcnew
StreamReader(“Message.txt”);result = reader->Read().ToString();
B. String^ result = nullptr;StreamReader^ reader = gcnew
StreamReader(“Message.txt”);result = reader->ReadToEnd();
C. String^ result =String::Empty;StreamReader^ reader = gcnew
StreamReader(“Message.txt”); while (!reader->EndOfStream) {
result += reader->ToString();}
D. String^ result = nullptr;StreamReader^ reader = gcnew StreamReader(“Message.txt”); result =
reader->ReadLine();
Answer: B
No comments:
Post a Comment