VS Compile Syntax RRS feed

  • Question

  • Apologies in advance, if this isn't the correct board to post on.


    Can anyone shed any light on the following code/syntax I came across the other day:


    Code Snippet


    #If Not CF Then

    Imports System.Runtime.Serialization

    #End If


    Does this allow a single class to be compiled differently depending on its target platform (i.e. If Compact Framework (CF) then import Serialization)?


    If so, are there any other syntax blocks that can be used?  For example, if the version number is above a certain number.








    Friday, July 6, 2007 3:16 PM


  • This looks like it is using a custom compile constant to determine what gets compiled and what doesnt.


    These constants are usually set in the IDE by

    Project properties -> Compile Tab -> Advanced Compilation Options -> Typing in the Custom Constants Textbox






    What will then occur will be these constants will be used to determine what to include in compilation and what to not include.


    In this case we are simply talking about importing a namespace to bring those methods into scope.


    I dont see CF defined as a system constant - so would assume that these are user defined.


    Hope that helps.


    Friday, July 6, 2007 10:38 PM