#include directive in c#

  • Thread starter Thread starter Max-Ph. Blickenstorfer
  • Start date Start date
M

Max-Ph. Blickenstorfer

I'd prefer to use C-Style #include directives to conditionally compile
classes in c#. The code should look like

#if (TEST)

#include <..\inc\this.cs>

#else

#include <..\inc\that_one.cs>

#endif

Any hints warmly welcome.





Regards

MAx
 
Max-Ph. Blickenstorfer said:
I'd prefer to use C-Style #include directives to conditionally compile
classes in c#. The code should look like

Then you are out of luck. C# does not support #include nor does it need it.

You can conditionally compile classes either by writing them directly in
your source file instead of the includes or you can wrap each individual
source file with your tests.

Yiou could also potentially find a preprocessor that has #include support in
or even run your code through a C++ preprocessor before each compilation,
but I'd recommend against it fervently.
 
you od the following:

#if TEST
public class Test
{
}
#endif

and in another file you can have:

#if ! TEST
public class Test
{
}
#endif
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top