How should you complete the relevant code?

DRAG DROP
You develop an application that displays information from log files when errors occur. The
application will prompt the user to create an error report that sends details about the error and the
session to the administrator.
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 during
this process.
You need to implement the method that reads the log files.
How should you complete the relevant code? (To answer, drag the appropriate code segments to
the correct locations in the answer are
a Each code segment may be used once, more than once, or not at all. You may need to drag the
split bar between panes or scroll to view content.)

DRAG DROP
You develop an application that displays information from log files when errors occur. The
application will prompt the user to create an error report that sends details about the error and the
session to the administrator.
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 during
this process.
You need to implement the method that reads the log files.
How should you complete the relevant code? (To answer, drag the appropriate code segments to
the correct locations in the answer are
a Each code segment may be used once, more than once, or not at all. You may need to drag the
split bar between panes or scroll to view content.)

Answer:

Explanation:
StringReader – Implements a TextReader that reads from a string.
http://msdn.microsoft.com/en-us/library/system.io.stringreader(v=vs.110).aspx
StreamReader – Implements a TextReader that reads characters from a byte stream in a particular
encoding.
http://msdn.microsoft.com/en-us/library/system.io.streamreader(v=vs.110).aspx
Once an exception is thrown, part of the information it carries is the stack trace. The stack trace is a
list of the method call hierarchy that starts with the method that throws the exception and ends
with the method that catches the exception. If an exception is re-thrown by specifying the exception
in the throw statement, the stack trace is restarted at the current method and the list of method
calls between the original method that threw the exception and the current method is lost. To keep
the original stack trace information with the exception, use the throw statement without specifying
the exception.
http://msdn.microsoft.com/en-us/library/ms182363(v=vs.110).aspx



Leave a Reply 10

Your email address will not be published. Required fields are marked *


Ravi

Ravi

async
await
ReadLineAsync();

Jun Yang

Jun Yang

ReadLineAsync: Reads a line of characters asynchronously from the current stream and returns the data as a string.

Mike

Mike

Why not ReadToEndAsync();?

Mike

Mike

Ok saw it now: “must return a string value that contains the first line of the response”. Only saw that after I read the opposite question at question 70.

playhard

playhard

stringreader class is similar to the streamreader class except that instead of reading file you are reading a string

Boubaker Echieb

Boubaker Echieb

so the right answer is streamReader ??!

Lord Vader

Lord Vader

the constructor to the stringreader class takes a string as a parameter. this isnt a path to a file but just a regulare sting that contains text.