Intro to Pre-processing Directives
Submitted by brian on Tue, 12/09/2008 - 3:31am.
So, I totally dig pre-processor directives. Use them all the time. Do you? I hope so! It can make a Debug build ready for a Release build with the change of a dropdown in Visual Studio.
Here's an example to change the logPath string if you're building in Debug mode (or anything else). This could be very handy with programmatically creating a log4net config.
string logPath; #if DEBUG logPath = @"C:\csharptocsharp.com\log.txt"; #else logPath = @"Q:\sites\csharptocsharp.com\logs\log.txt"; #endif
Anyway, if you're not using preprocessor directives in your code, then what are you waiting for?
Other References:
MSDN Preprocessor directives
Tags:
















