Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I set a system-wide _ifdef?

This is using Microsoft Visual Stuedio version 2019 with C#.

If I want to add specialized code to a project shared by multiple software developers that is designed for my selfish tests and evaluation, how do I manage a # definition inside the C# code?

I imagine some soft of solution varable that is deined in either the project file or the solution file that I do not merge with the master branch of the code in the version contorl system. And then this "# define" is somehow blocked out in the source file.

Has anyone experienced or used such a thing?

What I have tried:

I have gotten a good night's sleep.
I have had a good breakfast and drank plenty of fluids.
I am not going to try anything because I mighht break something.
Posted
Updated 21-Feb-22 6:24am

I am not sure I understand the question but C# preprocessor directives | Microsoft Docs[^] describes how to use the #if directive.
 
Share this answer
 
You can define a variable on a "per project" basis as part of the project "Properties ... Build" tab. Just add your symbols to the "Conditional compilation symbols" text box.

Then just add your conditional directives:
#if _XYZZY
            MessageBox.Show("Defined");
#else
            MessageBox.Show("Not Defined");
#endif
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900