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

Comments have been disabled for this content.