Simple ways to disable parts of code

后端 未结 14 1130
误落风尘
误落风尘 2021-01-31 08:59

This isn\'t a typical question to solve a specific problem, it\'s rather a brain exercise, but I wonder if anyone has a solution.

In development we often need to disable

14条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 09:15

    the following logic should contain the simplest approach

    if(isMode1)
    {
        //Code for mode1
    }
    else
    {
        //Code for other modes
    }
    

    although I think the correct way is to use PreProcessor Directives

提交回复
热议问题