Conditional Compilation

Hi!

Does anybody knows if there is a way to have conditional compileation in C# 1.1 I have a class file shared (using source safe) between a vs2003 and a vs2005. So far I managed to use only .net 1.1 compatible code, but know I want to add a few lines that will apply only when the class is used by the vs2005 project.

For instance:

string a = "string a";
string b = "string b";
#compile the following only on VS2005
string c = "string c";
#end




Answer this question

Conditional Compilation

  • AbhijitB

    I just don't want to have two separate files just for one or two lines of code.

  • ahewgill

    Hi Dimitris –

    Since the file is in SourceSafe, why not do a branch



  • JMDavis

    In your 2005 project, define a conditional compilation symbol "VS2005", and then code:

    #if VS2005
    string c = "string c";
    #endif

    David Anton
    www.tangiblesoftwaresolutions.com
    Instant C#: VB to C# converter
    Instant VB: C# to VB converter
    Instant C++: C# to C++ converter and VB to C++ converter
    Instant J#: VB to J# converter
    Clear VB: Cleans up VB.NET code
    Clear C#: Cleans up C# code



  • Conditional Compilation