I posted a riddle yesterday for my readers (I know there’s at least two of you ;).
Let’s compare the two methods:
|Conditional Attribute||Conditional Section|
|Compile Time||The call is compiled||No||No|
|The method is compiled||Yes||No|
|Compiler errors for any calls during compilation||No||Yes|
|Run Time||The call is made||No||No|
|The method is JITed||No||No|
The conclusion is that while using the Conditional Attribute may look better on your code, using the #if directive is more secure and slims down your file size (unwanted code is not compiled into the output file).
Keep this in mind the next time you need to add code that is called only if a certain symbol is defined.
I think I’ll stick to #if directives.