When #if DEBUG runs

后端 未结 7 601
星月不相逢
星月不相逢 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条回答
  •  Happy的楠姐
    2020-12-14 06:46

    #if DEBUG It's a preprocessor definition.

    It compiles when you define DEBUG constant. And yes, it's default on Debug Build Configuration.

    Visual Studio 2010 Project Properties: Visual Studio 2010 Project Properties

    If Define DEBUG constant is checked VS will compile:

    private const string BASE_URL = "http://www.a.com/";
    

    Else (not checked) VS will compile:

    private const string BASE_URL = "http://www.b.com//";
    

提交回复
热议问题