You are developing an application that will read data from a text file and display the file contents.
You need to read data from the file, display it, and correctly release the file resources.
Which code segment should you use?
A. Option A
B. Option B
C. Option C
D. Option D
“D” is correct!
Because the question is: “correctly release the file resources”
Close releases the used resources and Dispose releses the unmanaged resources
What? If exception will be thrown, how will be possible to execute Close and Dispose methods?
why not “D”?
“A” doesn’t “correctly release the file resources.”
“A” is correct. the file resources are correctly released.