What are two possible ways to achieve this goal?

You are testing an application. The application includes methods named Calculatelnterest and LogLine.
The Calculatelnterest() method calculates loan interest. The LogLine() method sends diagnostic
messages to a console window. The following code implements the methods. (Line numbers are included for
reference only.)
01
02 private static decimal CalculateInterest(decimal loanAmount, int loanTerm,
decimal loanRate)
03 {
04 decimal interestAmount = loanAmount * loanRate * loanTerm;
05
06 LogLine(“Interest Amount : “, interestAmount.ToString(“c”));
07
08 return interestAmount;
09 }
10
11 public static void LogLine(string message, string detail)
12 {
13 Console.WriteLine(“Log: {0} = {1}”, message, detail);
14 }
You have the following requirements:
the Calculatelnterest() method must run for all build configurations.
the LogLine() method must run only for debug builds.
You need to ensure that the methods run correctly. What are two possible ways to achieve this goal? (Each
correct answer presents a complete solution. Choose two.)

You are testing an application. The application includes methods named Calculatelnterest and LogLine.
The Calculatelnterest() method calculates loan interest. The LogLine() method sends diagnostic
messages to a console window. The following code implements the methods. (Line numbers are included for
reference only.)
01
02 private static decimal CalculateInterest(decimal loanAmount, int loanTerm,
decimal loanRate)
03 {
04 decimal interestAmount = loanAmount * loanRate * loanTerm;
05
06 LogLine(“Interest Amount : “, interestAmount.ToString(“c”));
07
08 return interestAmount;
09 }
10
11 public static void LogLine(string message, string detail)
12 {
13 Console.WriteLine(“Log: {0} = {1}”, message, detail);
14 }
You have the following requirements:
the Calculatelnterest() method must run for all build configurations.
the LogLine() method must run only for debug builds.
You need to ensure that the methods run correctly. What are two possible ways to achieve this goal? (Each
correct answer presents a complete solution. Choose two.)

A.
Insert the following code segment at line 01: #region DEBUG
Insert the following code segment at line 10: #endregion

B.
Insert the following code segment at line 10: [Conditional(“DEBUG”)]

C.
Insert the following code segment at line 05: #region DEBUG
Insert the following code segment at line 07: #endregion

D.
Insert the following code segment at line 01: #if DEBUG
Insert the following code segment at line 10: #endif

E.
Insert the following code segment at line 01: [Conditional(“DEBUG”)]

F.
Insert the following code segment at line 05: #if DEBUG
Insert the following code segment at line 07: #endif

G.
Insert the following code segment at line 10: [Conditional(“RELEASE”)]

Explanation:
#if DEBUG: The code in here won’t even reach the IL on release.
[Conditional(“DEBUG”)]: This code will reach the IL, however the calls to the method will not execute
unless DEBUG is on.
http://stackoverflow.com/questions/3788605/if-debug-vs-conditionaldebug



Leave a Reply 0

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