When #if DEBUG runs

后端 未结 7 604
星月不相逢
星月不相逢 2020-12-14 06:03

I have this code in my C# class.

#if DEBUG
        private const string BASE_URL = \"http://www.a.com/\";
#else
        private const string BASE_URL = \"h         


        
7条回答
  •  死守一世寂寞
    2020-12-14 07:05

    Go to "Project Properties"--> Build Tab of the application. If the Configuration: Active (Debug) then Debug configuration is enabled. Below code will print to console.

    #if DEBUG
        Console.WriteLine("in debug mode...");
    #endif
    

    If Configuration: Active(Release) then Release configuration is enabled.Below code will print to console.

    #if RELEASE
        Console.WriteLine("in release mode...");
    #endif
    

    If you want to switch between DEBUG and RELEASE mode use the "Debug/Release/Configuration Manager" drop down right under the Tools Menu.Apologies as most of the developer know it...but is sometimes overlooked and causes confusion why above code is not running correctly.

提交回复
热议问题