GIAC
GSSP-NET · Question #237
Allen works as a Software Developer for ABC Inc. He develops a Windows application. He adds a form to the application named Form1, which contains a Label control named Label1. A text file named…
The correct answer is A. InputString = Reader1.ReadLine(). See the full explanation below for the reasoning.
Question
Allen works as a Software Developer for ABC Inc. He develops a Windows application. He adds a form to the application named Form1, which contains a Label control named Label1. A text file named File1.txt contains a list of products. File1.txt is located in the application directory. Each product name is listed in a new line in File1.txt. Allen wants to retrieve a list of products from File1.txt and display it in Label1. He adds the following code to the application: 1. StreamReader Reader1 = new StreamReader((Stream)File.OpenText(Server.MapPath ("File1.txt"))); 2. Stream MyStream; 3. string InputString; 4. // Insert statement here. 5. while (InputString != null) 6. { 7. Label1.Text = String.Format("{0}{1}", Label1.Text, InputString); 8. Reader1.ReadLine(); 9. } 10. Reader1.Close(); Which of the following statements will Allen add at line 4 to accomplish the task?
Options
- AInputString = Reader1.ReadLine();
- BInputString = Reader1.BaseStream.ToString();
- CInputString = MyStream.ToString();
- DInputString = MyStream.Read(b,0,Byte1.Length).ToString();
How the community answered
(42 responses)- A79% (33)
- B5% (2)
- C12% (5)
- D5% (2)
Community Discussion
No community discussion yet for this question.