C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C #ifThe #if preprocessor directive evaluates the expression or condition. If condition is true, it executes the code otherwise #elseif or #else or #endif code is executed. Syntax: #if expression //code #endif Syntax with #else: #if expression //if code #else //else code #endif Syntax with #elif and #else: #if expression //if code #elif expression //elif code #else //else code #endif C #if exampleLet's see a simple example to use #if preprocessor directive. #include Output: Value of Number is: 0 Let's see another example to understand the #if directive clearly. #include Output: 2 Value of Number is: 1
Next TopicC #else
|