For example:
define.cs
#define FOO
form1.cs
#if FOO
MessageBox.Show("foo is set!");
#else
MessageBox.Show("foo is not set!");
#endif
the define.cs are included on same projet that form1.cs but the above condition give: foo is not!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t, but what you can do is move the define to the project configuration so that all files in the project can see the definition.
See the instructions in How to define a constant globally in C# (like DEBUG).