如何使用的#define从另一个文件? [英] How to use #define from another file?

查看:584
本文介绍了如何使用的#define从另一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

define.cs

#define FOO

Form1.cs的

#if FOO 
  MessageBox.Show("foo is set!");
#else 
  MessageBox.Show("foo is not set!");
#endif



define.cs 被包含在同一这谟 Form1.cs的,但上述条件给予:<!code> foo是不是

the define.cs are included on same projet that form1.cs but the above condition give: foo is not!

推荐答案

您不能,但你可以做的是移动定义的项目配置,以便在该项目中的所有文件可以看到的定义。

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.

请参阅说明书中如何定义一个全局常量在C#中(如DEBUG)

这篇关于如何使用的#define从另一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆