Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use #define from another file?

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!

like image 658
Jack Avatar asked Jun 06 '12 14:06

Jack


1 Answers

In C#, scope of #define is only limited to file in which it is declared.
To define a symbol visible in all files, one way is to Project->Properties->Build->Conditional Compilation Symbols and specify the symbol "FOO" there.

like image 146
vivek.m Avatar answered Sep 28 '22 19:09

vivek.m