PrepAway - Latest Free Exam Questions & Answers

Which code should you use?

You need to write a console application that meets the following requirements:
If the application is compiled in Debug mode, the console output must display Entering debug mode.
If the application is compiled in Release mode, the console output must display Entering release mode.
Which code should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
Programmatically detecting Release/Debug mode (.NET)
Boolean isDebugMode = false;
#if DEBUG
isDebugMode = true;
#endif
http://stackoverflow.com/questions/654450/programmatically-detecting-release- debug-mode-net

7 Comments on “Which code should you use?

  1. Seamus says:

    The correct answer is C.

    Tested in VS

    if (System.Reflection.Assembly.GetExecutingAssembly().IsDefined(typeof(System.Diagnostics.Debugger), false))
    Console.WriteLine(“Entering debug mode”);
    else Console.WriteLine(“Entering release mode”);




    4



    19
  2. ronzhong says:

    Answer: D

    using System;

    namespace _14_DebugReleaseConstant
    {
    class Program
    {
    static void Main(string[] args)
    {
    Console.WriteLine(“Hello World!”);

    #if (DEBUG)
    Console.WriteLine(“Debug mode”);

    #elif (RELEASE)
    Console.WriteLine(“Release mode”);
    #endif
    }
    }
    }




    0



    0

Leave a Reply