[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

preprocessir directives

Posted on 2006-11-09
2
Medium Priority
?
217 Views
Last Modified: 2008-02-07
Does C# have anything like in C -

#ifndef BLAH

#define BLAH
.......
.......
#endif

in C# I've tried #if (!BLAH)  #if (BLAH == false), both of which do not compile.

Naturally I can just say  #if BLAH  #else ..........  #endif, but I was wondering if C# supported the other.  Thanks
0
Comment
Question by:ARACK04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 15

Accepted Solution

by:
ozymandias earned 2000 total points
ID: 17906935
#if symbol [operator symbol]...
where:

symbol
The name of the symbol you want to test. You can also use true and false. symbol can be prefaced with the negation operator. For example, !true will evaluate to false.
operator (optional)
You can use the following operators to evaluate multiple symbols:
== (equality)

!= (inequality)

&& (and)

|| (or)

You can group symbols and operators with parentheses.

// preprocessor_if.cs
#define DEBUG
#define VC_V7
using System;
public class MyClass
{
   public static void Main()
   {

      #if (DEBUG && !VC_V7)
         Console.WriteLine("DEBUG is defined");
      #elif (!DEBUG && VC_V7)
         Console.WriteLine("VC_V7 is defined");
      #elif (DEBUG && VC_V7)
         Console.WriteLine("DEBUG and VC_V7 are defined");
      #else
         Console.WriteLine("DEBUG and VC_V7 are not defined");
      #endif
   }
}
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17906947
The above from MSDN C# Programmers Reference...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question