When #if DEBUG runs

后端 未结 7 597
星月不相逢
星月不相逢 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 06:51

    It's a preprocessor directive. The code in the DEBUG part is compiled when you do a debug build (more specifically when the DEBUG constant is defined). I.e. if you do a debug build BASE_URL will point to www.a.com. Otherwise it will point to www.b.com.

提交回复
热议问题