Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I easily exclude certain lines of code from a compile?

Scattered throughout a software project I am working on are many lines of code that were written for debugging and utility purposes. Before I compile my code, I want a way to select whether or not these blocks of code should be included into my compile (something that won't require navigating the code commenting out). How can I do this?

I'm programming in c# and using Microsoft Visual Studio 2010.

like image 639
Amichai Avatar asked Jul 02 '10 16:07

Amichai


1 Answers

Add the attribute [Conditional("DEBUG")] onto methods you only want to have execute in your debug build. See here for more detailed information.

like image 144
Jesse C. Slicer Avatar answered Oct 03 '22 22:10

Jesse C. Slicer