We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Platform : Windows Forms
|
Category : Debugging

How do I conditionally include certain methods based on some preprocessor defines?

You have the regular #if and #else preprocessor directive inside which you could place your code. Take a look at the "C# Preprocessor Directives" section for the complete list of preprocessor directives.

There is also a concept of "Conditonal Methods" that will let you declare some methods as conditional methods based on the presence of certain preprocessor directives, using the ConditionalAttribute. Then the compiler will not only ignore the method, but also the method-call if the preprocessor symbol is not defined. Take a look at this MSDN section for more information:

Conditional Methods Tutorial

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.