Conditional Attributes vs. Conditional Sections

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s