C# Preprocessor - Building different application versions

Aug 18 2004 6:32 AM
I have one question. I want to make application that in the VS solution configuration settins i will add new solution configuration "version1" and "version2". And in the code to use preprocessor, so if i'm building "version1" code that is applyed for version2 will not be visible in version1. Example: class aaa { public aaa() { variables.... methods.... #if VERSION1 some code here #else other code here #endIF } } So if i select VERSION1 is selected in VS solution configuration then this class will be compiles as it was like this: class aaa { public aaa() { variables.... methods.... some code here for version1 } } and if I select VERSION2 then class aaa { public aaa() { variables.... methods.... other code here for version 2 } } As for now #if DEBUG is working, bur how can I add new configurations and make them work. This is something like you do some code that will work on windows and linux, and instead to create 2 solutions and 2 projects where you will create 2 different versions you will have one solution and one project and by using preprocessor this can be achived.

Answers (2)