#define ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven Blair

    #1

    #define ?

    Hi,

    Does C# have something similar to #define (C/C++)

    I tried using the #define but didnt seem to work.

    Any help is appreciated.

    Regards,

    Steven
    A blog about computational biology, axolotls, and black cats.



  • Jon Skeet

    #2
    Re: #define ?

    Steven Blair <steven.blair@b tinternet.com> wrote:[color=blue]
    > Does C# have something similar to #define (C/C++)[/color]

    Well, that depends entirely on what you want it to do. You can use it
    for conditional compilation, but you can't use it for macros, constants
    etc.

    For constants, you should use const variables, and for macros you
    should just use methods.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Jasper Kent

      #3
      Re: #define ?

      Note the slight syntax differences from C++ too:

      The #define statements have to be the first thing in the file and the
      conditional is simply #if, not #ifdef or #if defined.

      Jasper Kent

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...