This is the archived version of Roland Weigelt's weblog that ran from 2003 to 2023 at weblogs.asp.net

Quick #if … #endif in Visual Studio

In my previous blog post “Commenting out Code in C# (Oldie but Goldie Tip)” I recommended using “#if … #endif” to disable code lines.

A quick way to do this in Visual Studio:

  • Select the code lines you want to disable.
  • Hit Ctrl+K, Ctrl+S to open the following popup:
    20200102_Popup
  • Press the Down Arrow key, then Enter.
  • Enter an undefined symbol name (e.g. DISABLED). Note: the default is “true”, which is defined and thus does not disable the code).

2 Comments