You develop an application that displays information from log files.
When a user opens a log file by using the application, the application throws an exception and closes.
The application must preserve the original stack trace information when an exception occurs.
You need to implement the method that reads the logfiles.
How should you complete the relevant code? (To answer, drag the appropriate code segments to the
correct locations in the answer area. Each code segment may be used once, more than once, or not at all.
You may need to drag the split bar between panes orscroll to view content.)
Answer:
(using StreamReader sr…
{
…
throw…
…
}
StringReader takes input as string and read over this input string.
StreamReader takes input as string of file path and stream over this file.
So answer is;
using (StringReader sr = new StringReader(“log.txt”))
throw;
Exactly as you said “StreamReader takes input as string of file path and stream over this file.”
so answer is:
using (StreamReader sr = new StreamReader(“log.txt”))
throw;
The Compiler will not execute the try inside using.
isn’t the syntax for using after interpretation/compilation
try
{
try
{
…
}
catch(FileNotFoundException ex)
{
throw;
}
}
finally
{
}
//since the exception is thrown in the outer try the try inside will never execute