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

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. Dim result As String = NothingDim reader As New
    StreamReader("Message.txt")result = reader.Read().ToString()
B. Dim result As String = NothingDim reader as New
    StreamReader("Message.txt")result = reader.ReadToEnd()
C. Dim result As String = string.EmptyDim reader As New
    StreamReader("Message.txt")While Not reader.EndOfStream
    result &= reader.ToString()End While
D. Dim result as String = NothingDim reader As New
    StreamReader("Message.txt")result = reader.ReadLine()

Answer: B

No comments:

Post a Comment