You need to ensure that the debugger breaks execution within the CalculateInterest()…

You are debugging an application that calculates loan interest. The application includes the following
code. (Line numbers are included for reference only.)

You need to ensure that the debugger breaks execution within the CalculateInterest() method when
the loanAmount variable is less than or equal to zero in all builds of the application.
What should you do?

You are debugging an application that calculates loan interest. The application includes the following
code. (Line numbers are included for reference only.)

You need to ensure that the debugger breaks execution within the CalculateInterest() method when
the loanAmount variable is less than or equal to zero in all builds of the application.
What should you do?

A.
Insert the following code segment at line 03:
Trace.Assert(loanAmount > 0);

B.
Insert the following code segment at line 03:
Debug.Assert(loanAmount > 0);

C.
Insert the following code segment at line 05:
Debug.Write(loanAmount > 0);

D.
Insert the following code segment at line 05:
Trace.Write(loanAmount > 0);

Explanation:
By default, the Debug.Assert method works only in debug builds. Use the Trace.Assert method if you
want to do assertions in release builds. For more information, see Assertions in Managed Code.
http://msdn.microsoft.com/en-us/library/kssw4w7z.aspx



Leave a Reply 5

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


sv1slim

sv1slim

“in all builds of the application” – the answer is A: Trace.Assert…

Lord Vader

Lord Vader

assert statement only executes in debug releases. in release builds the assert statement is ignored.

Lord Vader

Lord Vader

debug.assert takes a boolean value as its first parameter and throws an exception if the value is false.
in a degug build the assert method halts execution and displays a stack trace. in release it skips the call to assert so it continues even if boolean is false.

the trace class is defined for both the debug and relasse builds by default.

u can change this behaviour via build property page.
u can also u use define and undefine directives to define or undefine the DEBUG/TRACE at the code level.

YouCrackedMeUp

YouCrackedMeUp

in all builds of the application.
A is the answer.