(C#)Assume inputFile references a StreamReader object that is associated with a file that is already open. Which statement can read all the items in the file without knowing how many items the file contains? Question 9 options: while (!inputFile.EndOfStream) { } while (inputFile.EndOfStream) { } while (inputFile != EndOFStream) { } while (inputFile == EndOfStream) { }
Question 9 options:
|
while (!inputFile.EndOfStream) { }
|
|
while (inputFile.EndOfStream) { }
|
|
while (inputFile != EndOFStream) { }
|
|
while (inputFile == EndOfStream) { }
|
A)
while (!inputFile.EndOfStream) { }
If we want to read all the items which are located in a file, then we will use a while loop that could run as long as the end of the file hasn't been reached.
To find out if we have to reached the end of file, we will use EndOfStream method. If we have reached the end of file, then this method will return the value true, if not, then it will return the false value.
we will use the ! operator in order to make sure that the loop will run as long as the end of the file has not been reached. Therefore it can read all items in the file without knowing that how many items that the file will contain.
while (!inputFile.EndOfStream) is correct
Trending now
This is a popular solution!
Step by step
Solved in 2 steps