Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C#
C# Reference
 #elif
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
C# Language Reference
#elif (C# Reference)

#elif lets you create a compound conditional directive. The #elif expression will be evaluated if neither the preceding #if nor any preceding, optional, #elif directive expressions evaluate to true. If a #elif expression evaluates to true, the compiler evaluates all the code between the #elif and the next conditional directive. For example:

#define VC7
//...
#if debug
    Console.Writeline("Debug build");
#elif VC7
    Console.Writeline("Visual Studio 7");
#endif

You can use the operators == (equality), != (inequality), && (and), and || (or), to evaluate multiple symbols. You can also group symbols and operators with parentheses.

#elif is equivalent to using:

#else
#if

Using #elif is simpler, because each #if requires a #endif, whereas a #elif can be used without a matching #endif.

See #if for an example of how to use #elif.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker