You are debugging an application that calculates loan interest. The application includes the following code.
(Line numbers are included for reference only.)
01 private static decimal CalculateInterest(decimal loanAmount, int loanTerm,
decimal loanRate)
02 {
03
04 decimal interestAmount = loanAmount * loanRate * loanTerm;
05
06 return interestAmount;
07 }
You have the following requirements:
he debugger must break execution within the Calculatelnterest() method when the loanAmount
variable is less than or equal to zero.
the release version of the code must not be impacted by any changes.
You need to meet the requirements. What should you do?
A.
Insert the following code segment at tine 05: Debug.Write(loanAmount > 0);
B.
Insert the following code segment at line 05: Trace.Write(loanAmount > 0);
C.
Insert the following code segment at line 03: Debug.Assert(loanAmount > 0);
D.
Insert the following code segment at line 03: Trace.Assert(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